So lets say at a startup game company we had an EC2 running which ran both the web server and the app server for a game and communicated with RDS. As I understand, that’s kind of a two tier app instead of a three tier app because normally you would have a web tier with another EC2 handling HTTPS requests only and then sending that info to a private subnet App Tier where the game logic is computed in correspondence with the DB tier - then sent back to the web tier with the packets returned to the game device.
Is there anything inherently wrong in running both the web tier and app tier on the same EC2 for a small app? It would save cost from having additional EC2s when we’re capable of handling both a web and game logic in one tier. Since game servers need to run 24/7 I wasn’t sure that containers would make sense there.
2nd question: And as I understand, if you want to implement multi AZ with this structure, you use a load balancer which puts load balancer nodes in your public web tier subnets which can then talk to your app tier in (probably) a private subnet. Probably an autoscaling group of 1. In this case, you must use a NAT Gateway correct? Does the load balancer also return packets back to the game device or does the NAT Gateway do that on behalf of the app tier EC2s ? I was thinking with a two tier architecture you could just skip a set of EC2s to save costs and have the load balancer hit the EC2 running the web server and app logic in a public subnet.
What’s the best way to do either scenario? 1 AZ and Multi-AZ.
1st question: no I dont think there is anything “wrong” with this approach but there are a couple areas to consider. Scaling, now you must scale both the web server and the game server together. Logging within aws may be a bit harder to understand since one ec2 is handling multiple kinds of traffic. There is no separation of duty and thus you cannot separate these things into security groups to say restrict access of the db from the web app when the game app needs it.
2: I’m not positive on this one. the packet transport method I believe depends alot on how you configure your load balancer usually the load balancer is acting as a sort of proxy that the client is communicating with. The purpose of the nat gateway is to give a private network internet access without allowing the internet access inside of your private network. The nat gateway is a proxy that makes the requests on the (private) ec2s behalf.
note: this is my best understanding and may be incorrect.
A solution to some of this would be to containerize the game server and the web server so you still host them on 1 machine but you can route to specific containers vs 1 general machine.
If your primary driving goal is cost, then this is fine. But you are assuming some risks and single points of failure there that you have to be ok with to do so. Using a full 3 tier architecture will help you to eliminate SPOFs and increase uptime, but yes, will increase cost.
This looks like a single point of failure. Also with auto scaling both are scaling even if only the web or game host is at load.
The nat gateway is a proxy that makes the requests on the (private) ec2s behalf.
Ah. I got it. Had a brain lapse there. It must be that the packets just go out from the nat gateway to the internet gateway like normal with the addressing that’s been passed along from the load balancer.