- 1 million requests per day
- assume that all the expected requests in a day are going to be done in 4 hours
- one request takes 100ms of compute
- one request takes 40MB of memory
- stateless application, state stored in database
Please note: 100ms for one request is very heavy computationally, modern CPUs typically perform 5-10 instructions per clock cycle, Assuming only 1 instructions per 2GHz CPU core clock cycle, then one core can perform 2,000,000,000 instructions/second (or 2,000 MIPS). Let us assume 1000:1 ratio between high level programming language and machine instructions, then 2GHz CPU core for 100ms is very computationally intensive at 2,000,000 high level instructions.
RPS (Requests Per Second) = 1,000,000 / (4 hours x 3600) = 69.4
CPU Cores = RPS / (1 / function time for 1 RPS)
= 70 / (1 / 100ms) = 7
Memory = RPS x (function memory for 1 RPS) / (1 / function time for 1 RPS)
= 70 x 40 MB / ( 1 / 100ms) = 280 MB
Hence, to meet 70 RPS lets round up and we need 8 CPU cores and 512 MB.
See spreadsheet here comparing EC2 Autoscaling, EC2 Spotfleet, Lambda and Docker on EC2 for small, medium and large workloads, please note Lambda is sized 1536MB as due to poor performance of small memory functions::
No comments:
Post a Comment