DEV Community

Ashar
Ashar

Posted on

Serverless Architecture VS Monolith Architecture

Monolith-Server Architecture

  • Server Setup:

    • Utilize an EC2 instance (a virtual machine) from AWS.
    • Configure the instance based on initial requirements (e.g., 2GB RAM, 500GB Storage, 10MB Bandwidth).
    • Install necessary software (e.g., Linux, Node.js, Express.js) and deploy code.
  • Operation:

    • The server runs 24/7, ensuring constant availability.
    • Charges are based on hourly usage (e.g., $0.02 per hour).
    • Total monthly cost is fixed based on continuous operation.
  • Scalability:

    • Use AWS Auto Scaling Group (ASG) for handling increased traffic.
    • Automatically adjust resources (e.g., increase RAM to 6GB and Storage to 1000GB) as needed.
  • Management:

    • Full control over server configuration, software installation, and deployment.
    • Responsible for all server management tasks.

Serverless Architecture (AWS Lambda Functions)

  • Setup:

    • No need to configure or manage servers.
    • Write code and upload it to AWS Lambda.
    • Choose the runtime environment (e.g., Node.js).
    • Set up an API Gateway to trigger the Lambda function via a URL.
  • Operation:

    • Lambda functions do not run continuously; they execute in response to triggers (e.g., HTTP requests).
    • Charges are based on the number of invocations (e.g., $0.001 per invocation).
    • AWS handles scaling automatically to accommodate multiple concurrent requests.
  • Scalability:

    • AWS Lambda automatically scales to handle traffic, creating instances of the function as needed.
    • Ensures that no user experiences wait times during high traffic periods.
  • Cost:

    • First 1 million invocations per month are free.
    • Beyond that, charges apply (e.g., $0.20 per additional million requests).
  • Management:

    • Minimal management required.
    • AWS manages underlying infrastructure, scaling, and maintenance.

Summary

  • Monolith-Server Architecture:

    • Requires an EC2 instance and manual server management.
    • Fixed monthly costs based on continuous operation.
    • Full control over server and environment configuration.
    • Auto Scaling can be set up to handle increased traffic.
  • Serverless Architecture (AWS Lambda):

    • No server management required; AWS handles infrastructure.
    • Pay per invocation, reducing costs for low-traffic scenarios.
    • Automatic scaling to handle varying traffic loads.
    • Simplified deployment and maintenance, ideal for dynamic and scalable applications.

Top comments (0)