I am trying to come up with a design of document exchange system. System should be for business-to-business communication. Description: There will be possibly 100+ clients(consumers) - they will have to develop clients independently. Clients should send and receive documents.
Message Data:
- Author client ID
- Recipient client ID
- Document data (title, body, etc)
- Attachments
client IDs known for everyone
Whole document/message might become 200MB+ or even GBs (depending on how many attachments are presented).
There should be other similar operations to sending and receiving documents, that should follow the same principle, so I'm not listing them for brevity.
What methods I discussed:
- REST/SOAP - but there is no way to push messages to clients, when someone sent to them (one way is that client could have scheduler to regularly check if they have some documents to receive, which I don't like because messaging won't be instant).
- AMQP - even though solves the first problem, it has some limitations, like when some client sends me a document I cannot respond to them. For example: validation errors and etc.
- REST/SOAP for only sending and AMQP for only receiving messages. This just complicates everything.
Looking for suggestions, that could make my life easier, spend hours and hours but nothing good comes up to my mind.
Note: Messages might be 200MB+ in size and possibly represented as XML or JSON
Example flow:
client->sendDocumentRequest->server->sendDocumentResponse->client
server->pushDocument->some other client
I hope I explained well, if needed any more information for clarification, please ask. Thank you.
1 Answer 1
I just wanted to grab onto the message size, having designed server software with similar requirements.
I don't know the exact technology stack you would use, but the message size excludes a lot of solutions out of the box. Basically you don't want that whole message to be kept in memory, because even 1 message might use it up completely, 100s of clients would be almost impossible without a massive installation. The solutions for avoiding using memory:
Non-blocking zero-copy solutions. These don't use up threads nor memory regardless of message size, therefore they are the best for these sorts of things. You can either take something off the shelf (complete file transfer solution), or implement on top of something like vert.x (for JVM languages).
Streaming. Things like Servlets or other containers usually support this. This blocks a thread, and copies data a couple of times, but can support any message size with little overhead. For 100s of clients (using up a couple dozen threads) it would probably work.
Messaging. This wouldn't solve any of your problems directly. You would still have to read messages and avoid the same problems as above.
-
Thank you for suggestions! I'm going to build it using Spring framework.onlydmc123– onlydmc12303/13/2019 10:48:04Commented Mar 13, 2019 at 10:48
-
@RobertBrautigam Vert.x seems interesting. Have you implemented a web application with this framework? Is it based on the same principle as NodeJS? A single-thread on a event-loop?Laiv– Laiv03/13/2019 11:32:23Commented Mar 13, 2019 at 11:32
-
@onlydmc123 Spring falls into category 2. Still, that would probably be sufficient.Robert Bräutigam– Robert Bräutigam03/13/2019 11:48:09Commented Mar 13, 2019 at 11:48
-
@Laiv Yes, I used it for a web-application (for non-human clients), using Vert.x Web. It is using Netty under the hood, which is event based, but usually not single threaded, although it can be configured that way.Robert Bräutigam– Robert Bräutigam03/13/2019 11:51:21Commented Mar 13, 2019 at 11:51
-
Sounds interesting! Even if it's not single-threat. I don't know Netty, but I will check it out. I would like to have alternatives for Spring Boot when it comes to implementing web solutions or mere client-server. Something lighter and if it supports event-driven development much better.Laiv– Laiv03/13/2019 12:00:48Commented Mar 13, 2019 at 12:00
but this complicates everything (especially for clients)
who said it was going to be easy? 2 concerns 2 solutions. Divide an conquer