Project

General

Profile

Deploying Wt application with nginx

Added by Alan Finley about 11 years ago

Currently I'm deploying my app as a FCGI app under Apache. The main advantage of this approach is clear to me: Apache creates separate processes for different wt sessions, so if any session crashes, other ones will be ok.

Now I want to try deploying my wt app under nginx. I used this article from the wt wiki to configure my example. According to the article I should manually launch the FCGI process and configure nginx to serve requests for my app.

What is the difference between that configuration and deploying a wt app as a built-in web server or a wt server + nginx? In both cases we still have one process for multiple sessions.

The nginx doc says this: Unlike Apache or Lighttpd, Nginx does not automatically spawn FCGI processes

http://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_nginx

I know that I can launch several FCGI processes using the spawn-fcgi tool, but if any process crashes I don't have any built-in tool to launch it again.

So, is there any easy way to get benefits from multiprocessing under nginx like under Apache?

Also, I would like to add that my app does not only show static contents, but it has some extended interaction with a user and the DB. I don't want users lost their unsaved work due to app crash in some session, that's why I'm trying to use multiple FCGI processes.


Replies (2)

RE: Deploying Wt application with nginx - Added by Koen Deforche about 11 years ago

Hey,

The organisation of Apache/mod_fcgi vs Nging+spanw-fcgi is more similar than you would think.

The FastCGI process spawned by Apache or by spanw-fcgi is actually a 'forwarder/intermediate' process that does not run any Wt client code itself. Instead it will spawn either a few shared-session processes or processed dedicated to a single session. Thus your actually code runs in a different process that is managed by this intermediate process.

Thus using the same configuration file, both approaches have the same multi-process characteristics.

Regards,

koen

RE: Deploying Wt application with nginx - Added by Alan Finley about 11 years ago

Thank you for your answer. Now I have even more questions :)

Let's assume I launch my FastCGI process like this:

spawn-fcgi -n -f hello.wt -p 9091

What actually happens here? I've just started the 'intermediate' process? What happens when my app page is opened in a browser? That 'intermediate' process launches another process which runs my 'wt' code?

Why do I get 2 processes after I launch spawn-fcgi?

ps aux | grep hello.wt
root     20359  0.1  0.8 1190048 31512 ?       Ssl  17:44   0:00 /var/www/hello/docroot/hello.wt
root     20360  0.1  0.8 1189948 33772 ?       Sl   17:44   0:00 /var/www/hello/docroot/hello.wt client

Also I don't understand what the -F option for spawn-fcgi means: -F <children> Number of children to fork, defaults to 1. Is it a number of 'intermediate' processes or a number of my 'wt' processes?

How can I configure a number of processes that should execute my 'wt' code? How can I have separate process for every wt session?

And I want to ensure that I understand this correctly: errors in my 'wt' code won't crash any 'intermediate' process, it will crash just a 'wt' process?

Thank you.

    (1-2/2)