A
A
Arthur2017-04-04 14:40:54
Java
Arthur, 2017-04-04 14:40:54

How is it better to implement multithreading in a JAVA server program?

Hello! I'm trying to write 1 server in Java. Server for a mobile application, the server must accept a JSON request, process, search the database, generate and send a JSON response. The essence of the question is that I want to understand how on such a server it is possible to implement simultaneous work of, say, over 1000 - 10 ... 000 people? If possible, with examples. (A server is a program that can be located on more than one station). It turns out that 1 stream will contain such functionality as: receiving JSON, decoding, searching in the database, generating a response and sending it. And for each user 1 such stream?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
mitaichik, 2017-04-04
@mitaichik

Use Netty

A
al_gon, 2017-04-04
@al_gon

No way!
To implement competitive requests from 100,000 and beyond, you should look not at the programming language, but at architectural patterns, paradigms.
At one instance, more than one language "will not take out" so much. And what if it (the server) "fell"?

S
Sergey Gornostaev, 2017-04-04
@sergey-gornostaev

Much depends on "processing and searching". If you have this procedure fast and not demanding on memory, then 1000 requests per second Spring MVC will live without additional manipulations. But if the processing of one request is long or there are 10,000 requests, then the C10k problem appears . Only an asynchronous server will help you with this. Or a server cluster with load balancing.

D
Dmitry Roo, 2017-04-04
@xez

Exactly on this issue there is a video in which Heinz Kabutz tells everything in detail:
https://www.youtube.com/watch?v=uKc0Gx_lPsg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question