Still Linux Heavy CPU Usage for Standalone or CGI webApps in r3.3

I have reported a feedback for this few weeks ago ( feedback number 30303 ). The problem is still present on the 2013 r3.3 version.

Am i alone to have this CPU Usage issue deploying a webapp on Linux ? (tested on several Linux Distribution (RedHat Enterprise, Debian) and the same issue appears on MacOS X)

However, my standalone webapps on Windows works well without overloading the CPU (but i haven’t any Windows Servers in production environment :p).


I’m not having any issues on 2013 R3. I haven’t tried any of the later versions, but I just loaded 5 sessions on my R3 app and except for a short spike while the session was loading, the CPU stays under 20%. This is on a small EC2 instance running Ubuntu - a fairly low end VPS. It’s standalone behind nginx.

Back to my CPU problem …

Here is a sample Test project implementing a Server Timer (in thread) in my webApp. The Server Timer only increase a variable for everyone and each webclient displays it.

I’m doing something wrong ? Why the CPU consumption is so different ? (0% on Windows but 100% on linux)

Here is the sample project :

I don’t know why the thread sleep causes this under Linux only. I do wonder why you are using a thread as a timer instead of just using a timer (not WebTimer)? If your real app has a long process to run in the timer, then you could always spin off a one-time thread from the timer. But I believe that in web apps each session is a separate thread, so there’s probably no need to run long processes at the app level in a thread.


It’s possible it’s a Xojo bug in that version of the IDE. You should try an earlier version of Xojo and compare CPU usage.

I have not looked at your code and I don’t have Linux to test on but I ran your project on my Mac using the Xojo 2013 R3 IDE and it’s CPU usage was 2.5% to 2.6% on my Mac. For almost empty projects that’s typical for Xojo web apps.

For comparison I ran a one page xojo web app I’m developing which only has about a dozen items and it hovers around 3% CPU without doing anything.

Another test you can try with the IDE in question is to have a blank page and see it’s CPU usage on Linux.
I’d say if it’s significantly higher on Linux than it is on Mac and Windows then it’s most likely a Xojo bug.

Jay, i simply can’t achieve to make a Timer (via a class) to work (not a webtimer) in my webapp. I can instance it but it never calls the timer action :confused:

I certainly doing something wrong …

ok, i made the timer to work … i will see if it works better on linux :slight_smile:

Mikael, I also need to have a Timer working on server side. I also tried using a Timer (via class, not WebTimer) but as you mentioned, the action event does not triggers. How did you achieve this? Thanks!

Did you use AddHandler to connect a method to the action event? See The example is for a desktop app, but the same works for web apps also.

Simply :

1- Add a Class t your project with “Timer” as Super. Add the “Action” event on this class with the code you want to execute in your timer
2- Create a “MyTimer” APP property with the type “Timer
3- in Open Event Handler of the APP, add this :

MyTimer= new ClassTimer
MyTimer.Enabled=true ’ (this is added … just to be sure lol)

Now your Timer should work when your start your web app.

But the problem is still there. CPU is no longer at 100% but still too high (4/5% CPU with no clients and 5% more for each connected clients … so … with 19 clients … you reach the 100% CPU) … i have tried that with a little test project which only increment an integer every X seconds and no other properties. I don’t understand why the CPU is too high (if the timer run in a seperate thread by default, it seems that running a sub thread on linux has an issue). On windows … still no problem (but i haven’t any windows dedicated server… only Linux boxes)…

(i’ve forgotten to tell that you must call your timer class “ClassTimer” (or report your chosen class name in the code part) :wink:

Thanks Mikael. It worked.

In retrospective I know why it didn’t work before, but I will not share it cause it is embarrassing :stuck_out_tongue:

But Mikael, I have to say that I did not notice any particularly high load on the cpu. It was almost the whole time around 3% and peaked to somewhere around 15% for a very brief time when the timer triggered. I had two sessions working simultaneously and both went pretty much smoothly.

I tried on OpenSUSE 12.3 and with RS2012 2.1 in debugging mode. I will compile later to Xojo and let you know if I notice something.

Just a side note.
You can limit the CPU usage of a Stand alone WE app by installing CPULIMIT on your Linux VPS to tell that process to limit its allowed CPU usage in %. Quite handy if you have multiple apps running and don’t want any of em’ using 100% CPU…