Does anyone know any tool that might be used to identify those possible improvements/issue for multithreading application? For example, golang has a flag to identify race conditions, is there a library or bin/executable to check time waisted in any of these possible multithreading issues?
@JakobJenkov
7 ай бұрын
I don't know of any such tools, except performance benchmarking via JMH and see what comes out. Maybe look at the Java Flight Recorder or similar...
@mostinho7
2 жыл бұрын
Thanks for another interesting video We are waiting for how to implement concurrency on a single thread. Until you make that video, do you have any good resource to read up on how that might be implemented?
@JakobJenkov
2 жыл бұрын
Hi Mostafa, yes, I have an article about singlethreaded concurrency here (link below). I expect the video to be a bit more explanatory, but we will see :-) tutorials.jenkov.com/java-concurrency/single-threaded-concurrency.html
@americanstyle7333
Жыл бұрын
Thanks for sharing... It is Awesome! Another possible issue of Same-threaded Server may happen when the business logic modules of Thread 2 to M actually need a context level synchronization on their working data. It should be not a big problem when each business logic gets/puts data from a static source such as a central database. But it would need some burns in mind when each business logic for Thread 2 to M actually works only on cache data in memory, which is born from inbound connection requests, only serves the thread it was produced in, and the data will die with the thread. I was wondering whether it is a good design if, say, some inbound connection requests to Server thread 1 in such circumstances will duplicate itself into multiple copies, each assigned to the Selector queue for Thread 2 to M, run them in duplication, in order to achieve such an alignment that all threads have its business logic keep working on the same page. Could you share more on how such cache data driven scenario can be properly handled, how to secure that all thread have business logics working on the same page? Greatly appreciated!
@JakobJenkov
Жыл бұрын
I am not sure I understand exactly what the problem is in your case. A Samethreaded design would work for your case just as well as it would for any other case. If the threads need to share a cache, that cache needs to be properly synchronized, or use a non-blocking concurrency design.
@DeepakSiyal1
2 жыл бұрын
Hi @Jenkov can please clarify if this single threaded non blocking is the same approch that is followed in node js event loop,where server will listen for all clients,accept it ,put it into queue and return back to listening more request,while other thread that is event loop (single threaded) do all processing for queued requests and send back to clients the response,I am novice and just trying to explore all these internals ,apoligies if missed something or am wrong.Waiting for the reply if my undersatnding is correct. Thanks
@JakobJenkov
2 жыл бұрын
I don't know exactly how Node.JS works internally - but as far as I understand, Node.js works in a very similar way. It may not exactly be as I have described in this video, but it is most likely not that different (that is my guess / assumption at least - from what I have read about Node.js so far).
@nishiths9228
Жыл бұрын
loved the depth of the technical explanation that you provided and also having made it easy to digest the information.
@JakobJenkov
Жыл бұрын
Thank you ! Yes, I do spend quite some time on each video to make sure that all the necessary information is present, that it flows in the right order, and that it is easy to understand :-) Takes toooo long :-D ... so I am happy that it is useful to someone out there! :-)
@subashchandra989
2 жыл бұрын
Great Job Jakob ! Your explanation with example and diagram really make you better than others. Thanks a lot..Please keep it up..........
@JakobJenkov
2 жыл бұрын
Thank you very much :-)
@ehabahmedyassen
Жыл бұрын
Hi Jakob, i have a question about 16:05; since we can schedule 2 to M threads that can consume connections from the middle layer, isn't it better to assign a thread for each connection?
@JakobJenkov
Жыл бұрын
That is a question of what your network daemon is doing. For a server where traffic in and out stays on the same connection, one thread per connection can work. But for a router, where data coming in from one connection has to be routes out on another connection, having one connection per thread can easily get messy. Then you have many threads writing to the same connections... or you have to create some inter-thread communication system....
2 жыл бұрын
So you end up using the Reactor Pattern. Well, then say it. It has a nice catchy name. :)
@JakobJenkov
2 жыл бұрын
Actually, I end up using something which is slighly different than the Reactor pattern. I will explain it in a later video :-)
@panshenlian5063
2 жыл бұрын
如此棒的教程,怎么没有汉化版本
@Finn-jp6pn
2 жыл бұрын
Wow....this was exactly what I needed. Thanks, Jakob! Really helpful stuff
@JakobJenkov
2 жыл бұрын
You are welcome! ... that was lucky! :-)
@yahyanouali7524
2 жыл бұрын
Thanks for the great explanation. It would be nice if you give an implementation example :)
@JakobJenkov
2 жыл бұрын
I will - in future videos :-) ... I will have a single-threaded server design in my Polymorph Fabric project. It will also contain implementation examples of anti-thread-congestion designs, and single-threaded concurrency! ... as well as mechanisms for handling asynchronous tasks and non-blocking IO. This stuff is hard to get all in a single design - so the work moves slowly. But it's getting there :-)
@luisfernandogomez1535
2 жыл бұрын
Awesome! Thanks for the very good explanation.
@JakobJenkov
2 жыл бұрын
You are welcome! :-)
@SebastianBandera
2 жыл бұрын
very good, your tutorials are excellent !! ---- muy bueno, tus tutoriales son excelentes !!
@JakobJenkov
2 жыл бұрын
Thank you very much!! :-) It always makes me happy when people find my videos useful! :-)
@jsbarnum
2 жыл бұрын
Towards the end of the video, you talk about the problem of assigning multiple jobs to a single thread, and a fast job having to wait for a slow job to finish. Why would you ever do that? Why not put the jobs in a thread-safe queue so that the worker threads are only assigned a single job to do, and then they pick up the next job from the queue after completing it?
@JakobJenkov
2 жыл бұрын
The main reason would be to keep the number of worker threads down. If you put a fast task into a queue with some slow tasks already queued up - you will get the same effect of the slow tasks essentially delaying the fast job - unless you create a lot of worker threads - in which case you kind of defeat the purpose of the single-threaded design. In the designs I am currently working on - I would only use background worker threads for tasks that require blocking IO. Anything else I will use single-threaded concurrency for - which will more fairly and more controlled divide the CPU among the tasks.
@jsbarnum
2 жыл бұрын
@@JakobJenkov But if you have any number of worker threads > 1, then pre-assigning multiple tasks to any one of the threads risks starving the other threads for work. Putting them all in queue at least ensures that all of the worker threads will be busy as long as there is any work to do.
@JakobJenkov
2 жыл бұрын
BlockingQueue's become a point of congestion when you have many threads trying to take objects from them. As the number of threads grow that want to take objects from the same BlockingQueue, the throughput eventually starts *dropping*. That is why - for super high throughput designs - each worker thread gets its own queue which only itself and the load balancing thread accesses. This lowers congestion a lot! But - it results in the possibility of the situation I explained in the video. The ForkAndJoinPool solves this via "work stealing" where threads are allowed to try to "steal work from other threads' queues, if its own queue is empty. My solution is "single-threaded concurrency" instead. By the way - this concept of one-queue-per-worker-thread is also visible in the queue constructs in JC Tools. I will cover both thread congestion and single-threaded concurrency in more detail in future videos.
@wenqiangkong6186
2 жыл бұрын
简介明了的讲解了Java网络编程各种模型,很赞。
@JakobJenkov
2 жыл бұрын
Great that you found it useful! :-)
@ashishemc2
2 жыл бұрын
Concise and crystal clear explanation great video!!!
@JakobJenkov
2 жыл бұрын
Thank you very much! :-)
@singhvertika8167
2 жыл бұрын
awesome as always!!thanks for the video
@JakobJenkov
2 жыл бұрын
You are welcome! And thank you for your kind words! :-)
@shubhamdhingra6089
Жыл бұрын
Criminally underrated.
@JakobJenkov
Жыл бұрын
Thank you very much! :-)
@azatakhunov6061
Жыл бұрын
Thank you for your video! 👍 Liked the video. I found many answers to my questions in this video. One question remained a mystery after all. Can you suggest how, for example, on servlet containers, is it possible to change these parameters that would change the server type? Or, for example, in a spring boot, in an internal included the tomcat container.
@JakobJenkov
Жыл бұрын
Unfortunately, I can't! I don't know much about Spring Boot to help you out ! :-/
@Anon-xe6gf
2 жыл бұрын
Thanks for this informative and concise guide (same goes for your articles on your website)! I'm a software engineer student and would like to delve deeper into the theory and practice of high-performance server architectures. Do you know of some books / papers / source code / other sources to recommend for learning more? We have had one course on network programming and computer communication at uni, but is was rather surface level, barely touching on concurrency.
@JakobJenkov
2 жыл бұрын
I don't really know of any books that cover that topic. Most of the information that I have read, I have found in articles and blogs, and presentations on conferences etc. It's quite scattered, unfortunately. I do have some leve of information on jenkov.com - but not like a 100% easy-to-follow guide on high performance server designs. I am working on some designs at the moment though... some of my own designs :-) . You can also study the Java code for the open source Netty framework, as that is a commonly used high performance server toolkit.
@DeepakLalchandaniProfile
2 жыл бұрын
@Jakob Jenkov Where is the code ? 🤔. how to understand without code ?
@JakobJenkov
2 жыл бұрын
Hi Deepak, this video is only intended to explain the concept in a high level fashion. The "code" - the implementation - depends on whether you implement these types of designs yourself, or whether you use a framework that already implements this, such as Netty, Undertow, Vert.x etc. (note - that while both Undertwo and Vert.x use Netty internally, the way the interact with your code differs). I am also working on a toolkit that implements a single-threaded / same-threaded design - which does not use Netty internally. This project is called Polymorph. I will show some of these designs incl. code in later videos.
Пікірлер: 43