[Django]-EC2 Architecture design for Website

3👍

Completely dependant on how dynamic the site is planning to be. Do users generate content towards the service or is it mostly static? If the former you’re going to get a lot from putting stuff like avatars, images etc. into S3 and putting that on Cloudfront. Same with your static files… keeping your servers stateless will allow you scale with ease.

At 100k page views a day you will definitely struggle with just micros… you really should only use those in a development environment and aren’t meant to handle stuff like serving users. I’d use at a minimum a single small instance in-front of a Load Balancer, may sound strange but you will be able to throw in another instance when things get busy without having to mess with Route 53 or potentially having your site fail. The stateless stuff is quite important now as user-generated assets may only be reference able from one instance and not the other.

At 1k page views I’d still use a small for web serving and another small for MySQL. You can look into RDS which is great if you’re doing this solo, forget about needing to upgrade versions and stuff like maintenance, backups etc.

You will also be able to one-click spin up read replicas for peak. Look into the Amazon CLI as well to help automate those tasks. Cronjobs will make it a cinch if you’re time stressed otherwise Opsworks, Cloudformation and Auto-Scaling will all help with the above.

Oh and just as a comparison, an Application server of mine running Apache, PHP with APC to serve our users starts to struggle with about 80 concurrent users. Runs on a small EC2 Instance with a Small RDS (which sits at about 15% at the same time as the Application Server is going downhill)

👤Zac

1👍

  1. Probably not. Micro instances are not designed for heavy production loads. They use a burstable CPU profile. They can run at 2 ECU for a couple of minutes, and then they get locked at 0.1-0.2 ECU. I tend to like c1.medium, but small may be enough for you.

  2. Maybe, as long as they are spread out during the day and not all in a short window.

  3. 1-2 per core. Micro only has 1 core.

  4. Every application is different. The best thing to do is run your own benchmarks using tools like ab (Apache Bench)

1👍

Following the AWS best practices architecture diagram is always a good start.

http://media.amazonwebservices.com/architecturecenter/AWS_ac_ra_web_01.pdf

I strongly advise you to store all your files on Amazon S3, and use a Route 53 DNS (or any other DNS if you want) in front of it to distribute the files, because later on if you decide to use CloudFront CDN it will be very easy to change. And, just to mention using CloudFront as CDN will increase your cost only a little bit, not a huge thing.

Doesn’t matter the scenario, if we’re talking a about production, you should definitely go for separate instances, at least 1 EC2 for web and 1 EC2/RDS for database.

If you are geek and like to get into the nitty gritty details, create your own infrastructure and feel free to use any automation tool (puppet, chef) or not. Or if you just want to collect the profit, or have scarce resources to take care of everything, you should try Elastic Beanstalk (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html)

Anyway, going to create your own infrastructure or choose elastic beanstalk, always execute stress tests to have a better overview of your capacity planning needs. After you choose your initial environment, stress it using apache bench, siege or whatever other tool you may like.

Hope this helps.

0👍

I would suggest to use small instances instead of micro as micro instances often stop responding on heavy load and then it requires a stop-start. Use s3 for static files which helps in faster loading and have a look over cloud front.

The region for instance also helps in serving requests and if you target any specific region, create the instance selecting that region.

Create the database in new instance and attach ebs volume to that instance. Automate backup script to copy database files and store in ebs to avoid any issues. The instance selected here can be iops for faster processing over standard. Aws services provide lot of flexibility but you need to have scripts running to scale up and down the servers as per the timings.

Spot instance can help in future as they come cheap in case you are scaling up.

Leave a comment