Bulk Ops: Building a system that can handle 50,000 QR code download requests in one go.

Shubham Raj
Beaconstac Decoded
Published in
3 min readMay 23, 2022
Bulk QR Code creation

What is Bulk Download?

The bulk download is the feature using which you can download your QR Code images in all file types (PNG, JPG, SVG etc). This feature was built long ago and we had a max limit of 50 QR Codes you can download in one batch. But as the number of customers and QR Codes per account grew exponentially in the past 1 year. With the increase in enterprise customers who created QR Codes in bulk, we started getting requests from our customers to increase this limit as it didn’t make sense to make 20 requests to download all their QR Codes if they have just 1000 QR Codes in their account.

Issues with the existing system

Our old system was performing reliably great. But it was built using just one lambda function. When the download request reaches our server. Our server used to call the lambda function which generated all the images and sends them to the user. However, this lambda function can still scale up to some extent but it can’t handle a number greater than 100. So we didn’t want a temporary solution and we decided to build a system that can work for us in the long run.

Our new System

New System Design

Our target was to hit at least 25k QR Code downloads in one batch. So we built this simple and scalable system.

  • In our new system, as soon as our server receives the download request, It will process all the QR code data and push that to SQS Queue.
  • This queue triggers the lambda and depends on the number of QR Codes in the download request. It sets up the configuration of the ECS Task.

For Example, If the request has upto 100 QR Codes, It will set the configuration to cpu = 1GB, memory = 2 GB and partSize = 8

Similarly, if it is up to 200, We will set the configuration to the double what we set for 100

And for all the requests with more than 500 QR codes, We will configure a CPU of 4GB, the memory of 8GB and partsize of 24.

In this way, we make sure that our CPU configuration is dynamic and that it is not wasting memory for smaller requests and is fast enough to handle larger requests.

Now ECS Task generates all the QR Code images in the user requested file types, uploads them to S3 and zips them all in one zip file. It also adds a password to the zip file to make it more secure. It then uses SES to send this zip file to our customers informing them that their download request is complete. It also triggers a firebase notification which comes on our dashboard informing our user that your Bulk QR Code Download request is complete.

And the Results?

Now with our new system, we are able to generate images for 50,000 QR Codes in all file types in a single batch. Which is a huge number as none of our customers have so many QR Codes till today. This helped our enterprise customers a lot who had more than 1000 QR Codes in their accounts. Now they can easily download all of them in one go.

Want to build a system like this?

This wouldn’t have been possible without our super talented team members (Shashank Raj and Sourobrata) at Beaconstac.

If our work excites you and you also want to work on challenging projects like this then you can always visit our careers page. We are actively hiring for several engineering roles.

--

--