- Setup Apache and make a virtual host to listen it on other port like 8080
- Install varnish and listens it on port 80
- For the Varnish, you need to do configuration on two files like bellow
Here is the requesting flow: Browser ---> Varnish---->Apache2----->Application Server
That means, when u request through browser, it request to Varnish(on port 80) and if varnish has cached then it served directly to client(browser) without interfering apache otherwise Varnish passes the request to apache...In this way you can scale your Rails app heavily and serve a lot of requests concurrently with low memory and low resource consumed.
Some varnish useful commands:
That means, when u request through browser, it request to Varnish(on port 80) and if varnish has cached then it served directly to client(browser) without interfering apache otherwise Varnish passes the request to apache...In this way you can scale your Rails app heavily and serve a lot of requests concurrently with low memory and low resource consumed.
Some varnish useful commands:
- Restart Varnish - /etc/init.d/varnish restart
- Show Varnish statistics - varnishstat
- Test to see response is coming through Varnish -
curl -I http://www.your_app_url.com
It''s new for me that integrate http reverse proxy cache server with Rails and Varnish because I only know about the basics of Ruby on Rails Development and i would love to learn more.
ReplyDelete