Comments (13)
I would recommend you to use ack (acknowledgment of received data) https://github.com/mrniko/netty-socketio-demo/blob/master/server/src/main/java/com/corundumstudio/socketio/demo/AckChatLauncher.java
So you will send next message only then ack of recieved message sended by server to client. Because if you send it to server right after first message this leads to many waiting threads on server as a result, which will cause a performance degradation on server.
from netty-socketio.
Unfortunately it's not suitable for us as is. If processing takes 'long' time and acknowledge is sent before processing command we can meet this issue again, if ack is sent after processing we will have significant performance degradation as client will wait for each command to be processed which is not the requirement.
As for me, many threads should process messages simultaneously from different sessions, but messages from one session should be processed consequentially (with one or different threads).
In any case I have to add/use some mediator queue for commands either in my code or in your library. I'd prefer library.
If you are going to left such behavior as "feature" :) please give some advice where I could start to implement it within your lib.
from netty-socketio.
I'll add new option in Configuration class for this mode.
from netty-socketio.
Thank you very much!
Will look forward for it.
from netty-socketio.
But keep in mind, in case of using XHRPollingTransport like in your case or websockettransport if client don't get ping from server in certrain time interval it will drop connection. What do you think to fix this?
from netty-socketio.
It's a good question, but our 'long' is expected to be not so long to cause timeout...
Also, as socket.io has reconnection mechanism it may help us in critical cases (actually we never tested if it works for us :) and not sure that will be due to load balancing)
As for me, technical messages may be processed separately but there is few open questions. For example what to do if close session message is received? - close it immediately or wait while previous messages to be processed, etc.
Again, if processing became too long which means that server is overloaded, dropping some connections is not so bed solution, they will be rebalanced to less loaded one.
from netty-socketio.
Have you tried this simple trick in handler?:
synchronize(client) {
....
}
client instance will be always the same during session.
from netty-socketio.
Yes, I've added synchronization in code and it helps a lot.
We don't have simultaneous execution but as I understand commands reordering is still possible (can't check it for now), so it would be great if you implement feature in question.
In addition if there, for example, 10 clients with 10 commands from each and 5 worker threads there is possibility that all threads take commands from the same client and will be executed one by one, for this time there will be lack of threads for other clients.
from netty-socketio.
Take a look at this sample:
https://gist.github.com/4692912
I think it's right what you want!
from netty-socketio.
Thanks, it's something I've talked about at the beginning.
It solves thread starvation, but unfortunately doesn't prevent messages reordering :(
from netty-socketio.
It uses queue, so it should prevent messages reordering. Have you test it?
from netty-socketio.
Yes, messages will be processed in strict order, but they can be put in queue in wrong order the same way as before.
No I haven't tested it yet, will do when have time.
But as usual it's hard to test multi-threading code and it doesn't guarantee that it will work correctly on production. Especially on weird hardware like in our case.
from netty-socketio.
All messages processed in same order they came. And this https://gist.github.com/4692912 solution allows to queue handlers invocation in right order.
from netty-socketio.
Related Issues (20)
- I have to wait 20 seconds before restarting my java spring boot app because of SocketIO HOT 7
- Documentation is missing?
- Learn document need
- The negotiation timeout period is missing
- Memory Leak while WebSocketServerHandshakeException or Channel failed HOT 1
- Load Test - Netty writeAndFlush HOT 1
- This error IndexOutOfBoundsException is reported when receiving binary files HOT 3
- Hi, when the next release is planned?) HOT 1
- Hope to have an socket.io-client-java demo HOT 1
- netty-socketio 2.0.3 是不是不支持socket.io-client 3.0+ HOT 7
- Socketio established connection domain name path exception
- Jackson Unknown enum deserialising HOT 1
- 如何在服务端知道前后端是什么原因断开的?How does the server know the cause of the disconnection? HOT 4
- socket.io v4.6.0 js library cannot decode binary message from netty-socketio 2.0.6 HOT 7
- Context seems like an innapropriate label
- Android and Documentation
- Is it normal for 10,000 connections to occupy 1G of memory?
- A OOM problem was found in netty-socketio HOT 1
- Not support handle websocket ping frame HOT 3
- NPE when the ack response timeout HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netty-socketio.