[Gambas-user] ServerSocket doesn't appear to scale well

T Lee Davidson t.lee.davidson at gmail.com
Sat Mar 30 23:55:00 CET 2019


Okay so I coded up a multi-socketed server loosely based on the "Network Programming" example [0]. (I found that there's no need 
to maintain an array of Socket objects.)

I ran some tests using the Apache HTTP benchmark tool ('ab'). When sending the server 100 total and concurrent requests, it's 
performance is relatively impressive: Time taken for tests: 0.032 seconds.

But, if I hammer it with much more than 100 concurrent requests (about 150-200 I think), it starts to choke creating new 
connection Sockets very slowly. Even at only 100 requests, a test will sometimes not complete due to a time-out.

Any suggestions as to why that might be, and what I could do to open it up?

Here's what I have:

[code]
' Gambas module file

Public sPayload As String = "Hello World!"
Public sResponse As String = Subst$("HTTP/1.1 200 OK\r\nContent-Length: &1\r\n\r\n&2", Len(sPayload), sPayload) 'Nice. Thx Tobi.
Public Srv As ServerSocket

Public Sub Main()
   Srv = New ServerSocket As "Srv"
   Srv.Type = Net.Internet
   Srv.Port = 8080
   Srv.Listen()
End

Public Sub Srv_Connection(Host As String)
   Dim MySock As Socket
   MySock = Srv.Accept()
End

Public Sub Socket_Read()
   Dim sCad As String
   Read #Last, sCad, Lof(Last)
   Write #Last, sResponse, Len(sResponse)
   Last.Close
   ' Print Srv.Count
End

Public Sub Srv_Error()
   Print "Server error: " & Srv.Status
End

Public Sub Socket_Error()
   Print "Socket error: " & Last.Status
End
[/code]

BTW, I get no errors.


___
Lee

[0] http://gambaswiki.org/wiki/doc/network#t13


More information about the User mailing list