Designing a stateful web app

……in continuation of my last post.

To view my last post visit :

Let us look at some advance architecture design for a 3-tier application.

In the existing two tier application we now want our users to be able to add/retrieve data.

Question? Why do we need something at tier-3 if we can use cookies at the web browser level or enable stickiness at the ELB?

Answer: Yes, we can enable stickiness or use cookies but that might cause some issues.

  1. Stickiness may increase load on one EC2 instance.
  2. Cookies can be manipulated, max size is 4KB and cookies must be validated (extra effort).

To resolve this we can follow any of the below mentioned approaches.

  1. Elasticache and Amazon RDS: We can use elasticache to store/retrieve session data. In this way the user session data won’t be lost. Also, RDS can be used to store/retrieve user data (name, address, contact info,etc).

2. Amazon RDS Master with Read Replicas: We can also use RDS Master to write user data and use Read Replicas (can have up to 5 read replicas in RDS) to improve the read performance.

The benefits of using the above architectures can be:

  1. Enhanced Security: We can open up ELB from anywhere on HTTP/HTTPS and we can restrict direct traffic to EC2, since EC2 communicates only with ELB. We can also restrict traffic to Elasticache and the RDS security group from the EC2 security group.
  2. Disaster survival: We can enable ELB, Elasticache and RDS multiAZ to survive any unforeseen disaster that may occur.

Hope you’ll like this post!

Feel free to drop a comment or review.