Entire Web Server Hanging from CGI App

If the server is public facing you will have random pings from all over the place. It is just the way it is.

I think you’ll have an easier time tracking down any problems with your program logic if you deploy as stand-alone, as that’s essentially how the debugger runs your app. You’ll have more latency and typically less memory available in a deployed setting, though.

You may want to see for how long the cgi processes have been running. One of my apps suddenly stopped working not long ago and when I checked, there was something like over 40 instances of cgi which had been running for weeks. This app simply downloads a file, after which the user quits. It should have died by itself much before but did not. Since I implemented a timer that closes the session after 15 minutes, these ghost cgi have gone away.

Maybe the same is affecting your cgi ? 10 cgi processes for an app in progress sounds about realistic if sessions do not quit automatically.

More latency? I was thinking less latency. Why would standalone have more latency?

This sounds very familiar to what I am seeing. Have you considered using the WebSession.Timeout rather than a timer?

I probably should have now that you mention it. Was freaking because my customers could not access what they had bought, so I went for the quick. I will look into session.TimeOut. Thanks.

I know the feeling well.

[quote=104586:@Mark Pastor]More latency? I was thinking less latency. Why would standalone have more latency?
[/quote]

More latency than the debugger. See the sentence in context.

Got it - forgive my misinterpretation. However! on that note, I was looking at the Xojo UserGuide and found this …

Use CGI Rather than Standalone
You can build your app as a CGI or standalone HTTP Server.
Tests suggest that a standalone HTTP Server app should handle
a few hundred users without a problem. However, if you need
more performance, use CGI instead.

Any merit to that last sentence? If true - are we talking about differences that are substantive, or are the differences small?

The Xojo UserGuide is completely wrong there if that’s what it says. And also unhelpful, regardless. The number of users that a single instance your app can comfortably handle at once is almost wholly a function of your app and deployment environment. If you need to support more than a handful of simultaneous users, you should design load testing into your app from the beginning to you know how much memory, CPU time, and bandwidth each user needs (it’s a function of your app, not Xojo) and do the deployment math accordingly.

If you have to support a lot of simultaneous users, at some point, you’ll need to deploy multiple instances of your app. That opens up a whole nother can of worms, but it’s a much more flexible can if you’re already deployed as stand-alone.

Please file a bug report on the Xojo UserGuide. That’s not right.

Good feedback Brad - thanks.

34206 - UserGuide correction proposed re: CGI versus Standalone Web App

The docs are probably not stating some assumptions that would make that generally true.
In general, a single instance of the standalone should not perform as well a a single instance of the CGI simply because Apache is a much more capable web server that can/will run multiple instances of the httpd daemon where the stand alone will not.
HOWEVER, if you use a load balancing set up (say nginx or one of the other possible load balancers in front of it) and run numerous instances of the stand alone you can get pretty decent performance out of that set up.

Travis’ presentation on scaling web apps would probably be a good one for anyone needing to do this to have seen at the conference.

Is Travis’ presentation posted anywhere?

CGI normally requires less attention. Once installed, it will be run when requested by the user. If I understand right, a standalone has to be launched and kept active, otherwise the user finds a down site :frowning:

[quote=104776:@Norman Palardy]In general, a single instance of the standalone should not perform as well a a single instance of the CGI simply because Apache is a much more capable web server that can/will run multiple instances of the httpd daemon where the stand alone will not.
[/quote]

Whoah. The CGI still has to communicate with what is effectively a stand-alone web server, so you have that bottleneck regardless. If your app has any requests that result in large results, e.g. pictures, there is an additional implicit copy of the data done by the cgi.

Aside from the theory, it most certainly does not bear out experimentally.

[quote=104782:@Michel Bujardet]CGI normally requires less attention. Once installed, it will be run when requested by the user. If I understand right, a standalone has to be launched and kept active, otherwise the user finds a down site :frowning:
[/quote]

And if the app (essentially same as stand-alone) behind the CGI hangs up, you’ve got double the trouble detecting and relaunching it.

Stand alone does have some performance advantages- but it shouldn’t be run on the public internet directly. Always better to have those behind a reverse proxy to do SSL and handle any other requests up front.

CGI has the advantage of the application automatically launching/quitting as necessary. But a blanket statement about CGI performance isn’t accurate- so thanks for the bug report on the docs.

Is there any material to help me understand what this means, and how to do it?

You may want to read this thread: https://forum.xojo.com/4149-load-balancing-with-nginx/p1#p28982 that talks about the specifics of load balancing standalone instances with Nginx as the server.

It makes sense that the core of a WE program is the same between CGI and standalone. You would have trouble with any app that hangs anyway.

When last year I decided to replace a PHP script by a Xojo app, I knew Desktop but not Web edition. I have used Perl in the past and was familiar with CGI. It was a whole lot simpler to use CGI to replace the strategic delivery of software on my commercial web sites. I created the app, installed it on my server, and pretty much forgot about it. Apart from the zombie sessions problem I described above, I did not have to worry about the app being running.

More recently, by curiosity mainly, I inquired about standalone. I am familiar with SSH and can very well manage a standalone app on my server. But frankly I do not see myself monitoring the server everyday to check if the standalone is still running.

I know, Brad, you are a strong proponent of standalone and it probably is a tribute to your competence. But some users do not seek mastering the intricacies of SSH, and appreciate being able to simply upload, set permissions and be confident it runs. For them, Xojo Cloud is even better, that shields them from TCP.