There are usually around 300 users online at a time almost all the time, specially on the weekends. Recently we added a feature which incremented the network traffic considerably, since the users can be now in more than one room at a time.
It seems to be a problem related with the memory since we are getting errors like this:
Code: Select all
02 Dec 2012 21:03:27,663 WARN v2.controllers.ExtensionController -
java.lang.OutOfMemoryError
java.util.zip.Deflater.init(Native Method)
java.util.zip.Deflater.<init>(Unknown Source)
java.util.zip.Deflater.<init>(Unknown Source)
com.smartfoxserver.v2.protocol.binary.DefaultPacketCompressor.compress(DefaultPacketCompressor.java:38)
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler.handleWrite(BinaryIoHandler.java:99)
com.smartfoxserver.v2.protocol.SFSIoHandler.onDataWrite(SFSIoHandler.java:326)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketWrite(SFSProtocolCodec.java:158)
com.smartfoxserver.bitswarm.core.BitSwarmEngine.writeToSocket(BitSwarmEngine.java:392)
com.smartfoxserver.bitswarm.core.BitSwarmEngine.write(BitSwarmEngine.java:386)
[b]com.smartfoxserver.bitswarm.io.Response.write(Response.java:70)
com.smartfoxserver.v2.api.response.SFSResponseApi.sendExtResponse(SFSResponseApi.java:86)
com.smartfoxserver.v2.api.SFSApi.sendExtensionResponse(SFSApi.java:1321)[/b]
com.xxxxxxxxx.server.room.JoinRoomClass.joinRoom(JoinRoomClass.java:573)
com.xxxxxxxxx.server.room.JoinRoomClass.handleClientRequest(JoinRoomClass.java:643)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:192)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:133)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)I can replicate in the dev environment an outOfMemoryError limiting the heap space but then the error is
Code: Select all
03 Dec 2012 18:04:35,406 WARN v2.controllers.ExtensionController -
java.lang.OutOfMemoryError: Java heap spaceThe log says that the error happens when is trying to send an extension response. Actually is always the same line of code the one that triggers this error. After this the players who are playing can keep on doing it but it doesn't accept new loginRequests.
We've got a long queue for Extension Requests and for outgoing messages. My first thought was that the server was overloaded due to the server has got just a single core CPU and it just accepts 50 database connections. Probably there is a bottle neck that collapse the queue and a it triggers the memory error. The VM max memory is 1064 MB, what makes me hard to believe that we are saturating the memory. On the other hand I reckon that if the system cannot deal with the request and they keep on being received, the queue could grow really dangerously.
We incremented the number of threads listening to Extensions to 1000 to be sure that they could deal with the requests, but probably is not a good idea in a single-core CPU, I mean, I don't know if it is pointless. Maybe we should just improve the CPU.
After all this have been said, I've got two doubts:
What happens when smartFoxServer has got a memory error kind of thing? Could I read about that in any link. We use a Singleton object to store the game info, I've read the we should be using SFSExtension instead to maintain the common data accessible. Maybe this is causing that some players are playing in a different instance of the application and that's why the ones who were playing they can play after the failure.
Any idea about why the memory error is received after a sendExtensionResponse? Does it sound like a tunning problem?
Needless to say, any help would be more than welcome.