Skip to content

Performance & Rate Limiting


Respect Rate Limits

Why: Excessive requests degrade gateway performance for all merchants. If rate limiting is enforced, aggressive callers will receive 429 Too Many Requests responses, slowing their integration further.

Recommended approach:

  • Implement client-side rate limiting to stay within reasonable bounds (e.g., no more than 50 requests per second for status checks).
  • If you receive a 429 response, back off using exponential backoff before retrying.
  • Prefer webhooks over polling to naturally reduce request volume.

Use Connection Pooling and Keep-Alive

Why: Establishing a new TCP + TLS connection for every request adds significant latency (typically 100-300ms). Connection pooling reuses existing connections, reducing both latency and resource consumption.

Recommended approach:

  • Use an HTTP client library that supports connection pooling (most modern libraries do by default).
  • Enable HTTP keep-alive to reuse connections across requests.
  • Set sensible pool sizes: enough to handle your peak throughput, but not so large that you exhaust file descriptors.
import httpx

# Good — reuse a client with connection pooling
client = httpx.Client(
    base_url="https://api.payalo.com/gateway",
    headers={"X-Api-Key": API_KEY},
    timeout=30.0,
)

# Bad — new client per request (new TLS handshake every time)
def make_request():
    response = httpx.post("https://api.payalo.com/gateway/...", ...)

Batch Where Applicable

Why: If you need to initiate many transactions at once (e.g., bulk payouts), sending them sequentially one-by-one is slow and inefficient.

Recommended approach:

  • Use concurrent requests (e.g., async HTTP or a thread pool) to initiate multiple transactions in parallel.
  • Limit concurrency to a reasonable level (e.g., 10-20 concurrent requests) to avoid overwhelming the gateway.
  • Each request must still have its own unique merchantReference.

Note: The gateway does not currently offer a batch API. Concurrency is the recommended approach for bulk operations.