This article discusses cost comparison for microservices with a very high volume of API calls deployed on App Engine and Cloud Run.

The use-case for comparison:
  1. Our API is going to receive a very high volume of rest calls, say 30 million in a month.
  2. Each request is going to take approximately 500 ms to process on the server.
App Engine

We took F1 instance type in App Engine for our service in the experiment, wrote a simple “Hello world” API in python(Flask), and sent almost 35,000 API calls on it.

It took 12.12 instance hours to process these requests. So, on average 2887 requests get processed in each instance hour.

Now, in our use case, we are going to receive 30 million requests in a month, i.e. 1 million each day.

With this information, we can calculate that instance hours consumed to process 1 million requests (1million/2887) are 346. Therefore, instance hours consumed by 30 million requests in a month will be 10380.

Considering that for the F1 instance type, 28 instance hours are free per day, Google Cloud Platform will charge us on10220 instance hours after deducting the free quota.

So, the estimated cost for GCP App Engine to process 30 million records is $368.44 per month.

Image-2
Cloud Run

We created a service with 1 CPU and 256 MB of memory to handle 150 concurrent requests per instance, each with approximately 500 ms execution time and 5 minimum number of required instances.

Now, as per our use case, 30 million requests have to be processed. The estimated cost for this is $52.26 per month.

Conclusion

From the above cost estimations, Cloud Run seems to be a better service for microservices with a very high volume of API calls.