1

BACKGROUND: I have application server logic that hosts stateful object instances. I plan to have multiple servers - each hosting stateful object instances. NOTE: this is not a cluster with the same objects mirrored, but more of a federated model.

Each instance of my application server is using Netty and supports HTTP and WebSockets.

I wish to use the Netty WebSocket plumbing as the communication layer for not only server_1/server_2, but also for server_1/object_A talking to server_2/object_X.

For Example:

  • Server_1 has objects {OA, OB, OC} and Server_2 has objects {OX, OY, OZ}
  • S1:OA could communicate with S2:OX
  • S1:OB could also communicate with S2:OX

QUESTION (s):

  • 1) Is there a recommended approach to communicate between objects running in different servers using Netty? Are there any examples?
  • 2) Should I cache the Channel between servers and funnel all object-object requests over that? Is this thread-safe?
  • 3) OR, should I use separate Channels for server and object level communication - dynamically creating/destroying them as needed?

From a network utilization standpoint, I would think option #2 would be preferred for all bi-directional communication between Server_1 and Server_2.

If you need any clarification or more details, please don't hesitate to ask.

1 Answer 1

1

If you want to send over Java classes I would recommend to use the marshalling encoder/decoder that ships with Netty[1].

To your other question, all operations on a Channel are Thread-safe.

[1] https://github.com/netty/netty/tree/3/src/main/java/org/jboss/netty/handler/codec/marshalling

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, Norman! To follow-up on the options, am I correct in assuming 1 Channel between each respective server pairing would be recommended?
On the marshalling aspect, we don't actually need to send java objects across, but data - and we have our own binary serialization/deserialization logic. If we're using our own binary encoding/decoding, is there a specific set of classes we should derive from when building the pipeline?
It really depends on how your "logic" is.. Maybe FrameDecoder and OneToOneEncoder, but I can only guess without more infos.
Yes one Channel is the way to go
Excellent, thanks. As I'm cutting my teeth on Netty with this prototype, I'm sure I'll have some more questions as I dig deeper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.