Xojo Web Service: Faster Faster!

I’ve noted that a simple web service created with Xojo. Say…a web service that when you run it… just returns “Hello World” takes about 300 ms to return the result. Now…of course there is network latency etc. For comparison… a similar PHP web service running via Apache on the same system returns a response in about 120ms. I’ve run a hundred or so tests with the same average result. Since the Xojo program isn’t really doing much in my code…it’s got to be “spinning up a new session”. Seems like the solution is to keep one or more sessions “running” to service requests. Is this something that can be done in Xojo…and if so… will it actually improve performance or does it introduce other (possibly more) overhead?

Hi Robert,

Is it a “faceless” app listening on a specified port or a Web app deployed as CGI or Standalone?

Thank you!

Javier

Just thinking out loud here, but Aloe might generate a faster reply in scenarios where you don’t need to generate a web session: I’ve used Aloe in Xojo web apps specifically to handle one-off requests for inter-app messaging while letting other requests fall through to the normal part of the web app for on-going human interactive pages.

The app is a Xojo web app compiled for stand alone with no UI elements. Perhaps that’s the quickest way to create a web service with Xojo… but it doesn’t necessarily create the fastest performing web service. I don’t know anything about Aloe. I will investigate it. Thank you!

FWIW, a web app that just uses HandleUrl or HandleSpecialUrl does not create Session objects.

I will suggest that you compile as 64-bit Aggressive if you can. You may see some speed increases with that.

Charles had done some interesting tests https://forum.xojo.com/26481-xojo-vs-php-speed/ :

[quote=393998:@Charles Weger ]The bottleneck is not 64 bit, it’s the web app framework. I rebuilt the whole thing using raw TCPSocket and ServerSocket, parsing and forming the HTTP myself. Now Xojo is slightly (10-20 msec per call) faster than PHP. Woohoo!

So the web app framework is about four to six times slower than raw sockets for my endpoints-only use case.[/quote]

Why HandleURL/HandleSpecialUrl is not faster? A very low thread priority?

This is all very useful. Thank you so much. I wondered what effect using Xojo + Aloe might produce as suggested by Seth. I had never heard of Aloe but what an interesting project. I see the initial public release was just this year (Jan 2018). I decided to give it a whirl and I’m very pleased a simple service (hello world) returned in about 140 ms or so on average. This is actually on par with the response time I get from PHP running on Apache. Allow looks very handy with several sample use cases for doing all manner of things. I have a feeling I’ll find several good uses for it. I’ll read with interest Oliver’s link to performance tests, but I’ve got to give Seth a big thumbs up for pointing to to a great new tool for my arsenal. Aloe.

I might also point out that I tried switching to a faster network connection (known bulk transfer speeds up to 10x compared to the other network) to see what effect that would have. The Xojo Web application remained at around 300ms. The PHP + Apache app remained in the 120 ms range. However… the Xojo + Aloe application performed in the 65 - 80 ms range. Impressive.

Maybe Web Framework 2 get a speed boost when it ships?

I noticed when testing my Aloe / Xanadu apps that page loads are slower when I run the app over when I compile and run on Amazon Lightsail Linux. Maybe I just have too much other junk running on my MacBook Pro…

I tested Aloe, Xojo Web and Nginx with Apache Jmeter. The tests were relating to this thread - https://forum.xojo.com/47550-do-web-apps-have-minimumsocketsavailable-properties

These tests where done as part of my work for DocBlaster Pty. Ltd. who has agreed to release them here to further the cause.

I requested a 100kB png file 200 times simultaneously. I used my dev environment for these so they aren’t conclusive but give a general Idea.

Notice the peeks when the minimumsocketsavailable are reached.



Nginx static file server with caching turned off for comparison. Apache would probably be a fairer comparison.

It would be great to figure out how to get Aloe faster.

If you would like these results (and others) as CSV let me know.

EDIT: fixed image links

no images show for me

Google Pictures didn’t go so well for me. does it work now?

yepp, now I see them

Do you have any tests with Xojo HandleURL and Aloe behind NGINX?

Nginx will not randomly make it faster. The problem in my opinion is a very slow event loop. Perhaps they are using poll() or even slower/older select(). Suffice to say they need to be using epoll() or better yet incorporate libuv which is cross platform and does the best thing on all three platforms (http://libuv.org) to attain event loops speeds like Node/Nginx/etc does.

I should have clarified, the Xojo Web test above is from handleUrl. I tried handleSpecialUrl because I suspected it may be faster due to not opening a session. As Greg pointed out, this is not the case.

We have plans for more tests on a proper test server. We should probably add serving content from within sessions to the list.

Nginx (without PHP) isn’t really a fair comparison as it is static file server by default. Xojo via HandleUrl is more like a dynamic file server.

Nginx is dramatically faster due to it’s asynchronous event driven nature. It uses events to communicate with the kernel instead of thread blocking. Nginx will make a request for a file and then forget about it. When the file is ready the kernel will send an event to Nginx. Where as Xojo waits around for the file to be ready which prevents (or at least slows down due to context switching) other requests coming through.

EDIT: We don’t have a test of Aloe behind Nginx. Could that make any difference?

Very true, but it can offset load of static files which would let both HandleURL and Aloe apps focus on dynamic content. I should have qualified that better. :slight_smile:

What’s Aloe?

https://aloe.zone/
Aloe Express is a powerful, easy-to-use, open source Xojo Web server module. Build APIs, microservices, Web sites, and more.

@Dirk Cleenwerck Thanks.

Aloe looks very impressive - if the performance is that much better than Xojo’s web framework, why would I use anything but Aloe?