• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

WebSockets in Play and Scala - Suggestion needed

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if this is the right forum to ask my question. I have a client that I wrote using Scala and the Play framework. It is a WebSocket client that creates a WebSocket connection and keeps it open to send about 20000 messages roughly in Json format. The server processes these messages and sends back Json responses. How is the WebSocket client supposed to handle the responses from the client? The server sends the responses asynchronously and the client registers a handler which in turn receives the messages from the server. Is the onMessage handler in the client called sequentially for each message that gets sent from the server? Any ideas?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never used WebSockets, so take this with a grain of salt, but I am quite sure that if either side sends 20K messages, there is a better architecture to do it. That does not sound like a scenario WebSockets are meant to address.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I've never used WebSockets, so take this with a grain of salt, but I am quite sure that if either side sends 20K messages, there is a better architecture to do it. That does not sound like a scenario WebSockets are meant to address.



What is that better architecture? I'm a bit curious to know about it! The motivation to use a WebSocket is that the client and server would require to exchange messages via TCP frequently and there is no bandwidth to create a new connection everytime. I'm just trying to apply load on the WebSocket connection and see how the server and the client behave under such conditions.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you have not actually tried the scenario that you're worrying about, and it is just a test scenario to begin with?

The motivation to use a WebSocket is that ... there is no bandwidth to create a new connection everytime.


If there is a bandwidth issue then any communication will have problems. WebSockets are meant to address server-to-client communication (which generally is not possible with HTTP), and improve on latency (by not having to open a new connection for each message).
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please throw some light on the other architecture that you were mentioning? That would probably give me some ideas!
 
Ranch Hand
Posts: 56
Scala Mac OS X Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:If there is a bandwidth issue then any communication will have problems. WebSockets are meant to address server-to-client communication (which generally is not possible with HTTP), and improve on latency (by not having to open a new connection for each message).



There's more to that: the throughput of a websocket connection is a concrete improvement over the HTTP protocol, whose heavier payload (headers are sent with every communication) can become burdensome if you have a frequent exchange of small bits of content.
Joe's design could be the right solution, if the pure http scenario is verified as being too slow.

I too am curious about alternative designs.
Bye, Ivano
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The WebSocket end points proved valuable to us in achieving a better throughput. I like the idea and combining this with a non-blocking server like Netty is for me the way to go.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic