nginx and Perl: FastCGI vs reverse proxy (PSGI/Starman)

南笙酒味 提交于 2019-12-02 17:14:23

A reverse proxy setup (e.g. nginx forwarding HTTP requests to Starman) has the following advantages:

  • things are a bit easier to debug, since you can easily hit directly the backend server;

  • if you need to scale your backend server, you can easily use something like pound/haproxy between the frontend (static-serving) HTTP and your backends (Zope is often deployed like that);

  • it can be a nice sidekick if you are also using some kind of outward-facing, caching, reverse proxy (like Varnish or Squid) since it allows to bypass it very easily.

However, it has the following downsides:

  • the backend server has to figure out the real originating IP, since all it will see is the frontend server address (generally localhost); there is almost an easy way to find out the client IP address in the HTTP headers, but that's something extra to figure out;

  • the backend server does not generally know the orignal "Host:" HTTP header, and therefore, cannot automatically generated an absolute URL to a local resource; Zope addresses this with special URLs to embed the original protocol, host and port in the request to the backend, but it's something you don't have to do with FastCGI/Plack/...;

  • the frontend cannot automatically spawn backend processes, like it could do with FastCGI for instance.

Pick your favourites pros/cons and make your choice, I guess ;-)

HTTP is well understood by most system administrators and it's easy to debug. There's almost always some kind of reverse proxy already deployed, so it is a piece of cake to just add another configuration stanza to its configuration in order to bring your application up and running in a few seconds. Never tested the speed differances with both settings but on the other hand i never had any problems in that area, so it can't be that bad.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!