I've recently been inspired by a blog post from AudioBox highlighting some of their experiences with Amazon EC2 and why they switched over to a self-managed VPS. While the EC2 services certainly look useful, they seem a bit pricey for something I aughta be able to setup on my own.
This is uncharted territory for me, but I'm learning fast. After a bit a finagling, I managed to setup a simple network with a single load balancer running on Nginx, a database server, and two backend servers. And I'm using chef recipes to provision all these nodes on demand. Here's my very basic nginx.config
to make this all work:
upstream backend {
ip_hash;
server backend1.mydomain.net:8080;
server backend2.mydomain.net:8080;
}
server {
listen 80;
server_name mydomain.net;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://backend;
break;
}
}
}
One of the backend servers is sitting in EU, and everything else is sitting in a New York datacenter currently. I'm wondering how do I account for network latency? For instance, is a customer in the EU always going to have to go through my load balancer in New York in order to reach my EU backend? Should I add an additional load balancer and database server to my EU backend to further reduce latency for EU customers? And how do I ensure that requests are always routed to the closest available node?
Bonus Question
While my current setup works, it's only because I managed to MacGyver together snippets here and there from various blog posts and such. I don't really have a clear understanding as to how all these concepts fit together. Are there any good resources out there describing this paradigm I can refer to along my journey?