Web requests are a crucial part of any web application's functionality. However, problems can occur at any stage of the web stack, affecting the performance and functionality of your application. While most issues are related to the application server stage, understanding the entire web stack is essential for effective debugging.
- Web request processing
Web request processing
To debug a web request in Engine Yard, we should follow the path that a request will take in the web stack.
Load balancing: HA Proxy
Requests to Rails applications in Engine Yard always arrive through the application master instance, as it has a public IP. In this instance, the HA Proxy will be the component that first receives the request.
HA Proxy will take a request and send it to any of the available app instances, based on it's load-balancing algorithm. If you need to debug the HA Proxy configuration, you can check the file
The web server: Nginx
After HA Proxy, Nginx will receive the web request and pass it to the app server (Puma, Passenger, or Unicorn). Some ways to debug an Nginx request are the following:
- Check Nginx logs under
- Verify that the Nginx process is running with the command
ps -faux | grep nginx.
- Attempt to send a request to the local server with the command
curl localhost:8092. 8091 and 8092 are ports where Nginx is listening by default.
The application server
After the web server, the request will make it to the most complex element in the chain, the application server. Note that this is where a majority of the related reported issues will originate, as Nginx and HA Proxy are generally very stable in Engine Yard.
Please refer to The Rails Application Server in Engine Yard for a guide on how to debug issues related to the application server in Engine Yard.
Note: It is recommended that HA Proxy and Nginx are only referenced as needed, as a vast majority of issues will occur at the application server level.
Understanding the web stack and the path of a web request through the system is crucial for effective debugging. By following the process step-by-step, you can identify and resolve issues affecting any web requests.