Lifecycle of web app

[code]top - 15:45:35 up 1 day, 1:04, 0 users, load average: 0.11, 0.11, 0.09
Tasks: 30 total, 1 running, 29 sleeping, 0 stopped, 0 zombie
Cpu(s): 4.6%us, 3.7%sy, 0.0%ni, 91.5%id, 0.1%wa, 0.0%hi, 0.0%si, 0.1%st
Mem: 1016012k total, 939364k used, 76648k free, 10940k buffers
Swap: 0k total, 0k used, 0k free, 505472k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1603 customer 20 0 63048 16m 2568 S 1.9 1.6 10:53.99 Nelson2016
6277 customer 20 0 61380 20m 8328 S 1.9 2.0 0:01.69 Scott2016
6812 customer 20 0 61384 20m 8104 S 1.9 2.0 0:00.88 Clark2016
7271 customer 20 0 61680 21m 9104 S 1.9 2.1 0:00.43 Garrard2016
7452 apache 20 0 14888 1116 884 R 1.9 0.1 0:00.01 top
10216 customer 20 0 64760 16m 2924 S 1.9 1.6 0:57.86 Bullitt2016
24594 customer 20 0 62704 16m 2600 S 1.9 1.6 8:46.94 Shelby2016
1438 customer 20 0 61092 14m 3244 S 0.0 1.4 0:22.39 Garrard [/code]

In the above listing there are two processes related to apps that have been running for a LONG time. These applications simply look up a record in a database and display the results. As such I can’t imagine they would run for such a long time. These are CGI applications on the Xojo Cloud that have not changed in months. As a frequent XCTop user I don’t remember there being processes related to these apps in the hours range before.

I’m probably misunderstanding something but I thought that a user made a request, a page was rendered and then the process ended until there was another request. Is there documentation that describes the life cycle of a Xojo CGI web application?

Every browser connection creates a WebSession. WebSessions (by default) exist for three minutes after the last activity. The web app itself will only quit after all sessions have quit.

That said, there are some things that can prevent this from happening:

If App.AutoQuit is set to False, the app won’t quit when the last session closes.

If there are any leaks which prevent the WebSessions from closing, the app will not quit.

Thanks!

If “Every browser connection creates a WebSession” does that mean if two different users (browsers) connect to the same app two sessions would be started? Would these sessions show up as different processes in top?

Currently XCTop looks like this:

[code]top - 17:31:00 up 4 days, 2:49, 0 users, load average: 0.15, 0.19, 0.21
Tasks: 38 total, 1 running, 37 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.2%us, 3.0%sy, 0.0%ni, 93.7%id, 0.1%wa, 0.0%hi, 0.0%si, 0.1%st
Mem: 1016012k total, 990056k used, 25956k free, 62712k buffers
Swap: 0k total, 0k used, 0k free, 476572k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5234 apache 20 0 33636 4704 1980 S 5.8 0.5 0:00.03 index.cgi
5232 apache 20 0 14888 1124 884 R 1.9 0.1 0:00.01 top
17590 customer 20 0 66820 16m 2548 S 1.9 1.6 1:42.48 Oldham2016
24845 customer 20 0 61384 15m 2832 S 1.9 1.5 0:20.47 Clark2016
1957 customer 20 0 72984 16m 2556 S 0.0 1.6 1:02.19 Shelby2016
3970 customer 20 0 59132 19m 8036 S 0.0 2.0 0:01.90 Nelson2016
4717 customer 20 0 61680 21m 9108 S 0.0 2.1 0:00.99 Spencer2016
27058 customer 20 0 58344 11m 1352 S 1.9 1.2 4:03.08 Bardstown
1358 customer 20 0 59324 20m 8340 S 0.0 2.0 0:01.47 Scott2016 [/code]
The long running applications (Nelson2016, 10:53.99 & Shelby2016, 8:46.94) in the first post restarted sometime over the weekend. Now these process have much shorter TIME+ values as seen above. Since I seriously doubt a browser connection lasted over 10 hours and they don’t seem to fit the described behavior what happened to them? Neither have crashed with the mutex error and appear to be functioning normally. I have not restarted my cloud or deployed either.

Is App.AutoQuit True by default? Or do I need to set that?

Yes.

You would only see a single instance of your app, but there would also be an instance of the cgi script for each concurrent connection.

Apps can also be kept open by other connections, like search engines.

AutoQuit is True by default.