stateful web app
suppose a user connects with one insntace and adds to theri cart, they then again come and moved to a new isntnace, that is not in the cart now
we can do sticky session to solve it:
it will alsways keep ur users to be routed to same isntnace:
but if instance gets terminated the user will still lose their cart hence to solve it we use cookies:
the user will be storing the cart info, instead of the isntance doing the savign
it is hwoever better that ur instnace validate the cart in cookies
We will now be using concept of server session for faster connection:
instead of sending entire shopping cart we only send session ID:
EC2 instnace will be conencted to an elasti cache cluster and when user sends session id to elb, it is sent to instace, and it will then retrive from the cluster the partciular shooping cart ke session id
we can now store and retive user data using a RDS:
we can also do reads and make it easier by making read replicas:
lazy loading is basically first time instnace asks it wont be there it will be a miss, so it will be added to the cache by reading from the rds, next time new isntnace searches, they will find it there hence will be able to sned and read drieclty from cache, it will be a hit, this will reduce the pressure on rds: