Hosting a web application on Amazon Web Services. Cheap. Is it possible?

    Surely everyone has heard about Amazon Web Services (AWS). And some even looked at the Pricing page . And they noticed that prices there are noticeably higher than those of DigitalOcean, Linode, Hetzner Cloud, etc. Here is a table for comparing prices:

    Type ofRamCPUsDiskTrafficPrice
    Digitalocean-4 GB2 vCPUs80 GB4 TB$ 20
    LinodeLinode 4GB4 GB2 vCPUs80 GB4 TB$ 20
    AWSt2.medium4 GB2 vCPUs--$ 40

    Amazon takes money for traffic, and the prices are also not low:

    So why choose Amazon? Here are the reasons I see:

    1. A large number of useful services.
    2. Free Tier.

    On the second and will be discussed in this article.

    On the pricing page there is a link to a page with a free use level , which states that many services can be used free of charge for 1 year.

    This is quite enough for a whole year to keep free a full-fledged website or backend of a mobile application / game or something else. Besides:

    • You can have an arbitrary number of accounts (Amazon does not prohibit it, google on foreign forums), if the resources of 1 account are not enough.
    • You can configure the Auto Scaling Group, which will be 1 free VM, and at peak loads will be added paid on an hourly basis. You set the maximum number of VMs yourself.
    • After a year, you can create a new account, transfer data and use another year.
    • A year is enough for a beginner project to be bent or, on the contrary, to shoot.

    AWS pricing is very insidious, so I advise you to bind a virtual card to your account. Even at the level of free use, you can fly into significant amounts. Below I will share my experience.

    Pay-as-you-go pricing is scary because you can’t accurately predict end-month spending. Frankly, I would not use it if it were not for the experience gained at work, where for other people's money is not scary.

    When working with AWS, you need to be careful from the time of registration. From personal experience: when I registered for the first time, I chose the Developer tariff (well, I’m a developer, it means to me) and did not notice that this tariff has a subscription fee of $ 20 per month.

    So, what we have for free during the year after registration:

    • 1 virtual server (EC2) - 1 vCPU, 1 GB RAM, 30 GB disk, 1 static IP address (t2.micro).
    • 1 Redis or Memcached server (ElastiCache) - 1 vCPU, 0.555 GB RAM (cache.t2.micro).
    • 1 ElasticSearch server - 1 vCPU, 2 GB RAM, 10 GB disk (t2.micro.elasticsearch).
    • 1 MySQL, PostgreSQL or SQL Server (RDS) server - 1 vCPU, 1 GB RAM, 20 GB disk (db.t2.micro).
    • 1 load balancing (Elastic Load Balancer) - 15 GB of traffic per month.
    • File storage (S3) - 5 GB, 20K Get requests, 2K Put requests per month.
    • CDN (CloudFront) - 50 GB of outgoing data, 2M requests per month.

    Always free:

    • Email distribution (SES) - 62K messages per month.
    • Function as a service (Lambda) - 1M requests per month.
    • NoSQL database (DynamoDB) - 25 GB of storage, 200M queries per month.
    • API implementation tool (API Gateway) - 1M API calls per month, works in conjunction with Lambda.
    • Monitoring (CloudWatch) - 10 alerts for 10 metrics.

    Not applicable to Free Tier, but also free:

    • Certificate Manager - allows you to create SSL certificates for your domains for free, which can be used in Load Balancer, CloudFront and other Amazon services. But it will not work directly on virtual servers.

    How to keep track of costs

    After you have created the necessary instances, uploaded data, set up CloudFront, it is useful to set up CloudWatch and budget. Without this, you can get an unexpected bill at the end of the
    month for traffic.

    CloudWatch is a service for monitoring various metrics of your servers and utilized services: CPU usage, number of I / O operations and, most importantly, traffic.

    Using it, you can set up sending a warning by mail or call a webhook (for example, to send a message to Telegram) if the traffic has exceeded a specified value for a specified period of time. For example, send a message to Telegram if CloudFront traffic exceeds 1 GB in 5 minutes. The minimum available time interval is 1 minute.

    Screenshot of the CloudWatch page with customized alerts:

    The budget allows you to set a monthly cost limit, above which a warning will be sent, similar to CloudWatch. You can create up to 3 budgets for free.

    From personal experience: once I picked up a CORS-proxy on my server and one comrade (I won’t say how he learned about the existence of a proxy) started downloading YouTube through it. I discovered this when he managed to pump up $ 17, after which I stopped the proxy.

    Real example

    • 1 load balancer
    • 1 virtual server
    • Server Images for Load Balancer ($ 0.33 per month)
    • 1 Elasticsearch server for logs
    • 1 MySQL server
    • 3 DynamoDB tables
    • 2 domains in Route 53 ($ 0.5 for each, total $ 1 per month)
    • Static site on S3 with caching in CloudFront
    • Gateway API + Lambda - Service API

    Invoice screenshot for August:

    Total. AWS, with due care and attention, can significantly save on the initial stage of project development.

    Only registered users can participate in the survey. Sign in , please.

    What cloud service do you prefer for hosting personal projects?

    Also popular now: