have people tested the XOJO WEB'S performance?

Hi Olivier

trying to keep it as simple / easy as possible.

create a WE app

create a server socket
in the add socket event add this

Dim Ret as TCPSocket = New class1
Return Ret

Click on “add Class” (it will be called Class1 which is fine) and in the DataAvailable event put this

dim c as string
  
  c="<html>"
  c=c+"<head>"
  c=c+"<title>The EDi Cloud Load Balance Page</title>"
  c=c+"<meta HTTP-EQUIV=""REFRESH"" content=""0; url=http://"+ip+":"+str(5678+serv)+s+chr(34)+">"
  c=c+"<meta name=""keywords"" content=""automatic redirection"">"
  c=c+"</head>"
  c=c+"<body>"
  c=c+"If your browser doesn't automatically go there within a few seconds,"
  c=c+"please click here<BR>"
  c=c+"<a href=""http://"+ip+":"+str(5678+serv)+chr(34)+">The Edi Cloud "+str(serv)+"</a><BR>To be taken to The EDi Cloud Server "+str(serv)+"."
  c=c+"</body>"
  c=c+"</html>"
  
  s = "HTTP/1.0 200 OK"+EndOfLine+"Server: "+me.LocalAddress+EndOfLine+"Date: Fri, 21 Dec 2012 23:59:59 GMT"+EndOfLine+ "Content-Length: "+str(len(c))+EndOfLine+EndOfLine+c
  me.Write s

Now you need to know the IP address and PORT of where you are going to send them. I use 2 IP’s and 4 ports, which I have called 1,2,3 and 4 so my port is 5678 plus 1,2,3 or 4. I use 2 IP’s because I have 2 IP ( primary and backup) it works fine with just one so you can hard code the IP address or URL instead of “ip” in the code.

If you wanted to do it quickly just have a counter which +1 each connection, more of load spreading than balancing but you get the idea.

Thanks

Damon

Hi Olivier

trying to keep it as simple / easy as possible.

create a WE app

create a server socket
in the add socket event add this

Dim Ret as TCPSocket = New class1
Return Ret

Click on “add Class” (it will be called Class1 which is fine) and in the DataAvailable event put this

dim c as string
  
  c="<html>"
  c=c+"<head>"
  c=c+"<title>The EDi Cloud Load Balance Page</title>"
  c=c+"<meta HTTP-EQUIV=""REFRESH"" content=""0; url=http://"+ip+":"+str(5678+serv)+s+chr(34)+">"
  c=c+"<meta name=""keywords"" content=""automatic redirection"">"
  c=c+"</head>"
  c=c+"<body>"
  c=c+"If your browser doesn't automatically go there within a few seconds,"
  c=c+"please click here<BR>"
  c=c+"<a href=""http://"+ip+":"+str(5678+serv)+chr(34)+">The Edi Cloud "+str(serv)+"</a><BR>To be taken to The EDi Cloud Server "+str(serv)+"."
  c=c+"</body>"
  c=c+"</html>"
  
  s = "HTTP/1.0 200 OK"+EndOfLine+"Server: "+me.LocalAddress+EndOfLine+"Date: Fri, 21 Dec 2012 23:59:59 GMT"+EndOfLine+ "Content-Length: "+str(len(c))+EndOfLine+EndOfLine+c
  me.Write s

Now you need to know the IP address and PORT of where you are going to send them. I use 2 IP’s and 4 ports, which I have called 1,2,3 and 4 so my port is 5678 plus 1,2,3 or 4. I use 2 IP’s because I have 2 IP ( primary and backup) it works fine with just one so you can hard code the IP address or URL instead of “ip” in the code.

If you wanted to do it quickly just have a counter which +1 each connection, more of load spreading than balancing but you get the idea.

Thanks

Damon

Spillover sounds like a good idea, I just gave it a try.

You basically add 1 to the app.Port
If the current app is “full” you then forward the user to the next port, repeat until you find a sever with space.
Works nicely when a user finishes on the first server the next user will be put on to the first server. This would allow you to use your best computer as the first server and then worse machines as you go down the path.

The only problem I found was that if a user is being bounced 3 or 4 times it is quite a wait before you are shown a login screen or web page but there is no need for a separate program you build it all into the session.open event.

Thanks
Damon

Thank you Damon! I will study it. :slight_smile:

Damon: Excuse my ignorance here on Spilover. Wont that mean that server 2 (and 3 etc) will be totally idle until server 1 is at 100% capacity?

You could start ramping up the “spilling over” whenever, maybe 50%. The key is to keep it simple and self-contained. Otherwise, might as well nginx, etc.

Building a custom load balancer in Xojo seems a bit counter-productive. It would suffer all the same performance setbacks as the original Xojo app itself. Can only address 4gb RAM, only use single core, etc.

If you are going to load balance I’d recommend a hardware/software solution sitting in front of your standalone apps. You could also do it with PHP with better performance (than the Xojo version). Perhaps I’ll develop an example.

I’m not sure this matters much since the design being discussed is a simple HTML redirect. If it was a true TCP/IP forwarding service this could be an issue. But there’s no real load for an app that just says “hey, go to this address” and then forgets the connection.

PHP is not likely to be faster then Xojo at this. The times I’ve bench marked it Xojo code was as fast or faster then PHP. (If we had LLVM it would be a lot faster.) And PHP requires a host server. If you’re going to set that up might as well go for a “real” balancing solution via nginx.

Yeah but that’s not really load balancing thats just redirecting. If you have 2000 users all connecting at 8am at the start of the work day you will run into the same problems as if you just ran one web app.

Also keep in mind if this is for public consumption not everyone can connect to non-80/443 ports so just incrementing the port may not be suitable.

[quote=92771:@Daniel Taylor]
PHP is not likely to be faster then Xojo at this. The times I’ve bench marked it Xojo code was as fast or faster then PHP. (If we had LLVM it would be a lot faster.) And PHP requires a host server. If you’re going to set that up might as well go for a “real” balancing solution via nginx.[/quote]

Sure Xojo is faster at the process level. I’m talking about the lightweight situation where you are just handing requests off to something else. PHP can scale to more requests on a single 2+ core box then a Xojo app can.

I agree 100%. This is why I said earlier that people should just investigate nginx and HAProxy.

A Xojo console app that is only replying with redirect HTML might not have any problem with this. ServerSocket+TCPSocket can handle more then you might think.

That said, you bring up a good point that your load balancing solution has to be up to your expected traffic load or what’s the point.

Again, I agree 100% and would steer people towards an existing, “real” load balancing solution for reasons such as this.

I doubt this would prove to be a CPU bound problem. I could be wrong, but I just wouldn’t expect any real performance gain from using PHP for this.

[quote=92799:@Daniel Taylor]Again, I agree 100% and would steer people towards an existing, “real” load balancing solution for reasons such as this.
[/quote]

Regardless, evaluate your whole deployment context before choosing one or another. If you choose nginx, for example, you’ll probably need someone where the app is deployed to configure and maintain the installation. Great for a website with a budget, maybe not so great for an appliance or widget server that gets deployed on many devices/servers.