How to Load Test Public-Facing APIs
Public-facing APIs sit on critical paths for online shops, banking apps, booking platforms and government services. When traffic rises, small problems become visible: connection pools fill, authentication slows, queues grow and customers begin seeing timeouts. Load testing reveals how a service behaves under expected demand and where it breaks before real users discover the failure. It also provides evidence for capacity planning, infrastructure investment and reliability improvements.
A useful load test simulates realistic users, requests and data volumes rather than sending meaningless traffic at maximum speed. It should be treated as a controlled operational exercise, with clear approval, safety limits and measurable success criteria. For public-facing systems, the test must account for gateways, authentication, databases, third-party services and the behaviour of clients on Australian mobile and fixed-line connections.
Define objectives and guardrails
Start by agreeing on what the test must demonstrate. Useful measures include requests per second, concurrent users, response-time percentiles, error rates and the maximum sustainable load. Define which endpoints and user journeys matter most, then set thresholds for acceptable latency, availability and resource utilisation. These targets should reflect customer expectations and service-level commitments rather than generic benchmarks.
Convert those objectives into test scenarios. An unauthenticated catalogue request, a logged-in search and a transactional checkout may place very different demands on the system. A successful exercise might need to establish that checkout latency remains below a defined threshold while the platform handles a projected peak, with less than a specified proportion of failed requests. Capacity beyond that point is useful to discover, but excessive load creates risk without creating useful evidence.
Agree on stop conditions before the run. They can include elevated error rates, database saturation, queue growth, unexpected upstream failures or impact to genuine production traffic. Obtain written permission from system owners and account administrators, confirm cloud-provider quotas and use an approved testing account. Third-party payment, mapping, messaging and identity APIs should never be stressed without the provider’s explicit permission. Test against production only through a small canary phase after staging has passed.
Model realistic Australian demand
Australian traffic is geographically varied. Sydney and Melbourne contain large customer and cloud-provider concentrations, while Brisbane, Adelaide and Perth can experience materially different network conditions. Perth also sits three hours behind Sydney during Australian Eastern Standard Time. A model based only on requests collected from a Sydney office may underestimate latency and produce unrealistic arrival patterns for users elsewhere.
Local hosting choices influence the results as well. AWS regions in Sydney and Melbourne, along with major availability zones in Australian cities, can keep application latency low for many users. They do not remove distance effects for regional customers or third-party services. Run generators from several locations, including an Australian region and a remote location, then compare the results. This helps distinguish an application bottleneck from network routing, DNS resolution or TLS negotiation issues.
Connection variability matters too. Some customers use fibre or cable broadband, while others rely on NBN fixed wireless, mobile hotspots or congested mobile networks. These access methods can introduce jitter, packet loss and changing throughput during a test. Include realistic pauses and think times rather than assuming every user waits continuously for a response. Validate assumptions with historical API telemetry, gateway logs and analytics from Australian time periods.
Seasonal and commercial events can create sharp bursts. End of financial year activity, Christmas shopping, major sporting events and online sales can increase request volumes or alter data patterns. A retail API may need more capacity during evening browsing, whereas a business platform may peak during weekday working hours. Use historical evidence to identify these windows, and test the resulting spike instead of applying one average traffic figure throughout the year.
Prepare workloads and safe test data
Build the workload from recorded or representative request journeys. Vary endpoint, payload size, query complexity, authorisation status and pagination depth according to actual usage. Authentication tests should cover valid credentials, expired tokens, permission failures and token refreshes. Write operations need clean-up logic so repeated orders, payments or notifications do not pollute later results. Randomising every field can make a test unrealistic, while copying one request repeatedly can hide specific failures.
Load tools such as k6, JMeter, Locust and Gatling can generate HTTP traffic, scripts and reports. Choose one that your team can operate and that supports the protocol, authentication method and observability integrations required by the service. Give each scenario a realistic distribution—for example, frequent reads mixed with fewer writes—and configure arrival rates so users are not all forced into a single synchronised action. Test open and closed workload models where useful to examine capacity and user experience separately.
Use synthetic test data wherever possible. For covered organisations, personal information must be collected and handled for an authorised purpose under the Privacy Act 1988 and applicable Australian Privacy Principles. Production customer records should not be copied into a test system unless governance, access controls and the permitted purpose clearly allow it. Generate realistic but fictitious identities, mask sensitive fields and restrict access to the test dataset. Plan deletion or reset procedures so test information cannot be mistaken for genuine customer data.
Rehearse the script with a handful of requests, then increase traffic in controlled steps. Confirm that the generator itself is not consuming excessive network capacity, overwhelming local DNS or triggering the target’s abuse controls. Establish a baseline with little or no concurrent load, and verify that measurements are being recorded at both client and server boundaries. A defective script often produces convincing but meaningless performance results.
Execute tests and capture evidence
A staged run provides the clearest picture. Begin with a warm-up and low-load baseline, ramp gradually to the expected peak, hold that level to measure steady-state behaviour, and then introduce a controlled stress phase to locate the limit. Follow this with a soak test that runs long enough to reveal memory leaks, connection exhaustion and cache degradation. A short spike can separately show how autoscaling and rate limits respond to an abrupt surge.
Monitor the complete request path rather than only the public endpoint. Record metrics from the API gateway, web application firewall, authentication service, application servers, databases, caches, message queues and external dependencies. Watch median, 95th and 99th-percentile latency alongside average response time, because averages can conceal slow failures affecting a minority of users. Track throughput, error counts, timeouts, connection-pool use, CPU, memory, disk activity and queue depth.
Use correlation identifiers or OpenTelemetry traces to connect a slow client request to its internal components. The same identifier should appear in gateway and application logs, allowing engineers to determine whether time was spent waiting for authorisation, a database query or a downstream provider. Keep monitoring overhead low and test from infrastructure that will not distort the result. If load is generated from a laptop over a consumer connection, generator saturation may appear as an API failure.
Run the exercise during a suitable Australian operational window and keep the relevant support, engineering and infrastructure teams available. A small production canary can validate the final configuration, but it should remain within agreed limits and be easy to stop. Do not begin a major test during a known deployment, maintenance period or customer incident. Provide stakeholders with the start time, expected traffic profile, monitoring dashboard and abort criteria.
Analyse results and strengthen the API
Compare each phase with the baseline and the agreed thresholds. Rising latency can indicate queueing, resource contention or a slow dependency, while a sudden error-rate increase may reveal connection limits, invalid tokens or exhausted backends. A horizontal-scaling action that fails to improve throughput often points to a shared bottleneck such as a database, authorisation service or external API. Capacity estimates should reflect the highest stable level reached, with headroom based on the organisation’s risk and growth requirements.
Prioritise fixes according to customer impact and effort. Optimise slow queries and indexes, repair connection-pool settings, add cache controls, paginate large responses and reduce unnecessary upstream calls. For sudden bursts, token-bucket rate limiting can protect critical operations, while queues and backpressure can absorb temporary overload. Circuit breakers and timeouts prevent an unhealthy dependency from consuming every worker. Autoscaling needs suitable scaling signals, sufficient quotas and a realistic warm-up period.
Verify changes with the same workload and measurement method. A response-time improvement may be offset by a higher error rate, while caching can conceal backend strain until the cache is cleared. Record the tested configuration, scripts, data profile, generator locations and monitoring windows so another engineer can reproduce the result. Compare regular runs over time and repeat them after material releases, infrastructure changes or traffic-pattern shifts.
Communicate findings to product owners, security teams, support staff and leadership in language tied to customer risk and capacity. Record remediation owners and retest dates, and integrate the exercise with incident response and business-continuity planning. The Australian Signals Directorate’s cybersecurity guidance treats availability as a core security concern, while load testing supports practical resilience decisions. A sustained load-testing program turns one-off measurements into an early warning system that protects public APIs when Australian demand changes.