Need advice about which tool to choose?Ask the StackShare community!
AWS Lambda vs Celery: What are the differences?
Introduction
In this article, we will explore the key differences between AWS Lambda and Celery. Both AWS Lambda and Celery are popular technologies used for executing code in a distributed and scalable manner. However, they have some fundamental differences that set them apart from each other. Let's dive into the key differences.
Scaling Methodology: AWS Lambda scales automatically based on the incoming request load. It allocates resources dynamically and ensures that each request is processed independently and in parallel. On the other hand, Celery provides manual scaling by allowing users to configure the number of workers and concurrent tasks. It requires the users to manage the scaling of workers based on the anticipated load.
Event-Driven vs Task Queue: AWS Lambda is an event-driven computing service that allows developers to execute code in response to events like file uploads, database changes, or API calls. It focuses on executing specific functions in response to events, making it widely used in serverless architectures. Celery, on the other hand, is a distributed task queue that enables developers to queue and execute tasks asynchronously. It provides a broader scope for task management and coordination.
Execution Environment: AWS Lambda provides a managed environment where users can write and execute functions using various programming languages supported by AWS. It takes care of provisioning and managing the infrastructure required to execute the functions. Celery, on the other hand, requires users to set up their execution environment, including message brokers like RabbitMQ or Redis, and worker processes. It gives users more control over the execution environment setup.
Vendor Lock-in: AWS Lambda is a cloud service provided by Amazon Web Services (AWS) and is tightly integrated with other AWS services. Users may become vendor-locked when using Lambda as it requires utilizing the AWS ecosystem. On the other hand, Celery is an open-source technology that can be used with various message brokers and backends. It provides more flexibility and avoids vendor lock-in.
Pricing Model: AWS Lambda follows a pay-as-you-go pricing model, where users are charged based on the number of requests and the amount of compute time used. It provides a detailed billing structure and automatic scalability based on demand. Celery, being an open-source technology, does not have any direct pricing associated with it. However, users need to consider the infrastructure costs for hosting the message broker and worker processes.
Deployment and Management: AWS Lambda provides a seamless deployment experience as it is integrated with other AWS services like AWS CloudFormation or AWS Serverless Application Model (SAM). It simplifies the management of serverless applications and automates deployment. Celery, being a self-hosted technology, requires users to manage deployment and infrastructure on their own. It requires additional efforts for deployment and configuration management.
In summary, AWS Lambda and Celery differ in their scaling methodology, execution environment, event-driven vs task queue approach, vendor lock-in, pricing model, and deployment/management experience.
I am just a beginner at these two technologies.
Problem statement: I am getting lakh of users from the sequel server for whom I need to create caches in MongoDB by making different REST API requests.
Here these users can be treated as messages. Each REST API request is a task.
I am confused about whether I should go for RabbitMQ alone or Celery.
If I have to go with RabbitMQ, I prefer to use python with Pika module. But the challenge with Pika is, it is not thread-safe. So I am not finding a way to execute a lakh of API requests in parallel using multiple threads using Pika.
If I have to go with Celery, I don't know how I can achieve better scalability in executing these API requests in parallel.
For large amounts of small tasks and caches I have had good luck with Redis and RQ. I have not personally used celery but I am fairly sure it would scale well, and I have not used RabbitMQ for anything besides communication between services. If you prefer python my suggestions should feel comfortable.
Sorry I do not have a more information
When adding a new feature to Checkly rearchitecting some older piece, I tend to pick Heroku for rolling it out. But not always, because sometimes I pick AWS Lambda . The short story:
- Developer Experience trumps everything.
- AWS Lambda is cheap. Up to a limit though. This impact not only your wallet.
- If you need geographic spread, AWS is lonely at the top.
Recently, I was doing a brainstorm at a startup here in Berlin on the future of their infrastructure. They were ready to move on from their initial, almost 100% Ec2 + Chef based setup. Everything was on the table. But we crossed out a lot quite quickly:
- Pure, uncut, self hosted Kubernetes — way too much complexity
- Managed Kubernetes in various flavors — still too much complexity
- Zeit — Maybe, but no Docker support
- Elastic Beanstalk — Maybe, bit old but does the job
- Heroku
- Lambda
It became clear a mix of PaaS and FaaS was the way to go. What a surprise! That is exactly what I use for Checkly! But when do you pick which model?
I chopped that question up into the following categories:
- Developer Experience / DX 🤓
- Ops Experience / OX 🐂 (?)
- Cost 💵
- Lock in 🔐
Read the full post linked below for all details
Pros of AWS Lambda
- No infrastructure129
- Cheap83
- Quick70
- Stateless59
- No deploy, no server, great sleep47
- AWS Lambda went down taking many sites with it12
- Event Driven Governance6
- Extensive API6
- Auto scale and cost effective6
- Easy to deploy6
- VPC Support5
- Integrated with various AWS services3
Pros of Celery
- Task queue99
- Python integration63
- Django integration40
- Scheduled Task30
- Publish/subsribe19
- Various backend broker8
- Easy to use6
- Great community5
- Workflow5
- Free4
- Dynamic1
Sign up to add or upvote prosMake informed product decisions
Cons of AWS Lambda
- Cant execute ruby or go7
- Compute time limited3
- Can't execute PHP w/o significant effort1
Cons of Celery
- Sometimes loses tasks4
- Depends on broker1