An API receives 120 requests in a second when a shop opens, then spends most of the afternoon quiet. Google Cloud Run is an appealing home for it. The service can run a container and adjust the number of instances as traffic changes. The surprise is how much of the result depends on how many requests each instance can handle at once.
Estimate the work in flight
Suppose the busy period sustains 120 requests per second and the average request spends 250 milliseconds in the service. That works out to 30 requests in flight on average (120 × 0.25). If you configure concurrency at ten, three instances would have 30 slots on paper. Three is a capacity illustration. Bursts, startup time, uneven work, autoscaling targets, and the database can all move the real instance count. Cloud Run concurrency
Now change one detail. If those 250 milliseconds consist mostly of waiting for a database connection, increasing concurrency may just create a longer queue for PostgreSQL. If they consist mostly of single-threaded CPU work, ten simultaneous requests on one instance may take turns on the same core. In a trial, compare tail latency, instance count, and database checkout time at two concurrency settings. A lower instance count is only a win if customers are still getting timely responses. How to budget PostgreSQL connections across instances
What happens after the HTTP response?
Cloud Run’s request-based billing is well suited to a handler that finishes its work before sending its answer. Instance startup and shutdown also count, and keeping minimum instances warm changes the idle-cost calculation. Instance-based billing charges for an instance’s whole lifetime and makes CPU available outside requests. Neither choice by itself gives an unfinished task a durable record if the instance goes away. Billing modes · Minimum instances and idle pricing
For a receipt download, the distinction is practical. A request that reads a prepared receipt and returns it fits an HTTP service. A batch that regenerates 40,000 historical receipts can run as a Cloud Run job. It writes its output and exits with a success or failure code. If an HTTP endpoint starts that batch, hand the work off durably and return a job identifier the caller can check. Cloud Run jobs · Container runtime contract
Price the quiet hour as carefully as the busy one
A service with zero minimum instances can scale down when idle. Setting a warm minimum can reduce the startup delay for the first shopper, and it introduces an idle baseline. Compare two versions of the estimate in your production region. In one, the service starts from zero after a long gap. In the other, one instance stays warm. Include the database running through that same gap, the request volume, and outbound transfers. Summing every request’s wall time can overstate instance time when requests overlap. Cloud Run pricing
Cloud Run would be high on my list for a containerized HTTP API with uneven traffic and a team willing to measure its busiest endpoint. Before switching over, try a request after a long idle period, a sustained rush, and a slow database query during that rush. Record what the shopper experiences in each case. Those three measurements make a better case for the platform, or against it, than a monthly request count on its own.