Speed Up CGI Launch Times

Follow this simple tip to speed up launch times for WE CGI apps.

The short, short version: WE CGI apps quit when there are no users. The next user has to wait for the app to startup again. If you have a dedicated server or VPS, eliminate this delay by adding Self.AutoQuit = False to App.Open.

One of the frequent complaints found on the Realbasic forums and mailing list is that Real Studio WE applications have a lengthy startup time. I’ve found that the perception of a long startup time is due to several factors:

  • WE loads multiple pages at startup, including any ImplicitInstance pages or pages you create in App.Open. Of course this results in very fast page switching once things are running.
  • WE shows a startup screen. A simple, single page site doesn’t necessarily take longer to load then a PHP page, but the startup screen carries a psychological factor. We’re used to seeing pages draw onto our screen. But a progress bar makes us think “Oh great, I’m waiting.”
  • CGI deployments often have to launch the WE application.

That last point is in bold for a reason. The default behavior with a CGI app is for the app to quit once the last Session closes. So if a user finished with your site 15 minutes ago, and a new user comes along, that new user has to wait for the app to launch. Even on a dedicated server the delay is quite noticeable.

The solution? For dedicated servers and VPS accounts, add this line to your App.Open event:

Self.AutoQuit = False

Now your app will stay open even when there are no Sessions. For obvious reasons you shouldn’t do this with a shared hosting account. And even with a server or VPS you should keep an eye on your app to catch any memory leaks. But if your app is solid and your hosting situation allows for it, this one change can significantly improve the perception of speed.

Keep in mind when you do this that you will have to kill the running application process any time you update the application file on the server. You normally have to do this any way. Here’s how.

Leave a Reply

Your email address will not be published. Required fields are marked *