B4J Question [B4J] stress test

Widget

Well-Known Member
Licensed User
Longtime User
A tool to stress test a websockets b4j server?

Why not use one of the many free stress test utilities that are already out there? I don't think you should limit yourself with a stress tester written in B4J otherwise you would be using the same architecture to test itself. (If there was a hypothetical flaw in B4J, then it would prevent the stress tester from running at full speed too!)

http://www.google.ca/search?client=opera&q=free+stress+test+websocket+software
 
Upvote 0

dar2o3

Active Member
Licensed User
Longtime User
The problem is that almost all are focused on testing only http / https protocol and not found any (to work) on websocket, so I wonder if anyone knows any tool that works.
 
Upvote 0

dar2o3

Active Member
Licensed User
Longtime User
Thank you very much for your reply, when you have some free time I will try to create a basic tool for this, I will make available to the community for those who want / can enter improvements, I think it could be a nice community project.
 
Upvote 0

dar2o3

Active Member
Licensed User
Longtime User
I'm trying to make the tool we've talked about, the first thing I want to do is a test connections, for that I think many jwebsocketclients and just hope that connect to see which is the maximum number supported by the server connections.
I'm doing it in b4j, but I find the problem by reaching the 309 connections (jwebsocketclient) I get the following error.

B4X:
java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:714)
    at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
    at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1587)
    at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:334)
    at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533)
    at org.eclipse.jetty.util.thread.ScheduledExecutorScheduler.schedule(ScheduledExecutorScheduler.java:111)
    at org.eclipse.jetty.io.ManagedSelector$Connect.<init>(ManagedSelector.java:614)
    at org.eclipse.jetty.io.SelectorManager.connect(SelectorManager.java:190)
    at org.eclipse.jetty.websocket.client.io.ConnectionManager$PhysicalConnect.run(ConnectionManager.java:76)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)
java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:714)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.startThreads(QueuedThreadPool.java:462)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.doStart(QueuedThreadPool.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.addManaged(ContainerLifeCycle.java:343)
    at org.eclipse.jetty.websocket.client.WebSocketClient.initializeClient(WebSocketClient.java:465)
    at org.eclipse.jetty.websocket.client.WebSocketClient.connect(WebSocketClient.java:198)
    at org.eclipse.jetty.websocket.client.WebSocketClient.connect(WebSocketClient.java:155)
    at anywhersoftware.b4j.objects.WebSocketClientWrapper$1.run(WebSocketClientWrapper.java:51)
    at java.lang.Thread.run(Thread.java:745)
WebSocket Closed: unable to create new native thread



The code I'm using to create the connections is as follows

B4X:
Sub Btniniciar_MouseClicked (EventData As MouseEvent)
  
  
    If Txtnmaquinas.Text<>"" Then
        Dim wsc(Txtnmaquinas.Text) As WebSocketHandler
        For i = 0 To Txtnmaquinas.Text -1
            Try
              
          
            wsc(i).Initialize(Me, "wsh")
            wsc(i).Connect(serverLink)
            TxtLog.Text=TxtLog.Text & I & CRLF
            Log(i)
          
          
            Catch
                TxtLog.Text=TxtLog.Text & LastException & CRLF
                Log(LastException)
            End Try
            Next  
        Else
      
    End If

  
End Sub

if I run the program 3 times at once, no problem in creating websocketclient 308 each (total 924 or more).

upload_2016-6-7_11-14-23.png
 

Attachments

  • upload_2016-6-7_11-13-43.png
    upload_2016-6-7_11-13-43.png
    301.3 KB · Views: 173
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
If I remember well (this happens... never :D) Erel's tests work well with 2,000 connections.

He will understand better the error message (also because I read not well :D) but I think "instinctively" to two possible problems:

1) I would create a new connection (websocket) in the Connected event of the previous connection
2) (less likely) device memory problems
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
If I remember well (this happens... never :D) Erel's tests work well with 2,000 connections.

He will understand better the error message (also because I read not well :D) but I think "instinctively" to two possible problems:

1) I would create a new connection (websocket) in the Connected event of the previous connection
2) (less likely) device memory problems

Why am I trying to help someone even when I have no correct solutions?
Probably because I'm terrified of addressing the design issues of my project, coward! :D

Then comes Erel with the right solution and I also have to be ashamed.

Stop answer, "Luca".
 
Upvote 0

dar2o3

Active Member
Licensed User
Longtime User
jajaja, I read whenever you make me smile.

Turning to the problem.
1
I "instinctively also" do not think the problem is you have to wait for the first connection is realize to go for the second (308 correct connections are made without any problem)

2
If the problem is memory, I could not run another 300 connections in another, and tried running up to 4 programs at once and no problem.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is better to use a non-ui application to create a stress test.

You need to give more memory to the processes. See how it is done in this example (near the end of the post): https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/#content

This will only have an effect when you run the program from the IDE. You can add these arguments to the command line.

With that said, you will soon hit other limits such as the maximum number of open sockets.
 
Upvote 0

dar2o3

Active Member
Licensed User
Longtime User
Thank you very much for your reply.
I wonder if it would be a good choice, use a ui-application (to display data, set ip, to launch sql from the app, etc ...) to launch one or more non-ui application to do the dirty work.
 
Upvote 0
Top