Tue. Aug 9th, 2022

First, we will see the flow of spring-mvc.

Whenever a web server gets a request, a new servlet thread is assigned to it. It takes the request and do
some processing. After that, it makes a database call. Database call is an I/O operation between our web
server and the database. During the database call, this servlet thread is going to a waiting state. It is on
waiting state until database driver fetches the data bundle. Once it gets data successfully, the servlet
thread gives response to the client. This is the normal flow of spring-mvc.

If another request come into the web server during this servlet thread waiting period (during I/O
operation) a new servlet thread is assigned to it and the same process is continued.

Let us say that we have many concurrent requests into the web server. Imagine our web server thread
pool size is 200. Assume that the web server gets 200 requests within the same time. In such a case, 200
servlet threads are created and database calls are made to fetch data. If more of the web server
requests come, they have to wait until the rest of the servlet threads do their operations and release.

In this case, more number of web requests have to wait until other servlet threads are released. If the
server handles more number of concurrent requests, server always gets busy and resource usage
becomes high. Therefore, we want better mechanisms to serve more number of concurrent requests
more efficiently.

What we ideally want is, whenever the request comes, we assign a servlet thread (ST1) and do some
processing. Then instead of waiting for the thread to complete the I/O operation, we tell the database
driver to notify to the servlet thread to receive the response once the I/O operation (OP1) is completed.
While doing that, the I/O operation servlet thread can serve another server request and make a
database call to make the I/O operation (OP2) and release. During that time, if the previous I/O
operation (OP1) is completed, the servlet thread (ST1) or any other servlet thread can get the output of
I/O operation (OP1) and send that response to the client. In this mechanism, servlet thread does not
need to stay in a blocking state and waiting for the I/O operation. This mechanism can be used to avoid
the servlet thread going into a blocking state or a waiting state. If we expand this concept to all the
available threads, this call back event base mechanism. This mechanism is call as event loop.

In this event loop we have limited number of servlet threads to serve the user requests. Whenever there
is a request, it does some basic process and immediately delegate the request to the database driver for
I/O operation as an event. On the other side, database driver will take the event, and will do the I/O
operation and whenever it is ready with the data it also fires an event saying ‘I am ready with the data’.
After that any of the threads can get the response of I/O operation and can give to the client.

If we visualize traditional request and event loop request handle mechanism, it is as follows.

By admin

25 thoughts on “What is WebFlux in Spring?”
  1. I’m curious to find out what blog platform you’re working with?

    I’m experiencing some small security issues with my latest blog and I would like
    to find something more safe. Do you have any solutions?

  2. You actually make it seem really easy along with your presentation but I
    in finding this matter to be really something which I think I might by no means understand.
    It kind of feels too complex and extremely huge for me.
    I’m having a look ahead to your subsequent post, I’ll try to get the cling
    of it!

  3. Greetings, I do think your website could be having
    web browser compatibility issues. Whenever I take a look at your blog in Safari, it looks
    fine but when opening in IE, it’s got some overlapping issues.
    I just wanted to give you a quick heads up! Besides that,
    wonderful website!

  4. Usually I don’t read post on blogs, however I would like to say that this write-up
    very pressured me to check out and do it! Your writing style has been surprised me.
    Thank you, quite great post.

  5. This is really interesting, You are an excessively professional
    blogger. I’ve joined your feed and look forward
    to searching for more of your fantastic post. Also, I’ve shared your web site in my social networks

  6. It’s the best time to make some plans for the future and it’s time
    to be happy. I’ve read this submit and if I may I wish to suggest you some attention-grabbing things or suggestions.
    Perhaps you can write subsequent articles relating to this article.

    I want to learn even more things approximately it!

  7. Hi there! Quick question that’s totally off topic. Do you know how to make your site mobile friendly?
    My blog looks weird when viewing from my iphone. I’m trying to find a template or plugin that might be able to fix this issue.

    If you have any recommendations, please share. Cheers!

  8. I just like the valuable info you provide to your articles.
    I will bookmark your weblog and test again right here regularly.
    I’m moderately sure I’ll be told many new stuff proper right here!
    Good luck for the next!

  9. Wow that was unusual. I just wrote an extremely long comment
    but after I clicked submit my comment didn’t show
    up. Grrrr… well I’m not writing all that over again.
    Anyways, just wanted to say excellent blog!

  10. That is really fascinating, You’re an overly skilled blogger.
    I’ve joined your feed and look forward to searching for extra of your wonderful post.
    Also, I’ve shared your website in my social networks

  11. Hi, I do believe this is a great web site. I
    stumbledupon it 😉 I may come back yet again since I bookmarked it.
    Money and freedom is the best way to change, may you be rich and continue to guide other people.

    my website; Sharyl

  12. Have you ever considered about adding a little bit more than just your articles?

    I mean, what you say is important and all. Nevertheless
    think of if you added some great graphics or video clips to
    give your posts more, “pop”! Your content is excellent but with images and clips,
    this site could certainly be one of the best in its niche.

    Terrific blog!

  13. I do trust all of the ideas you have introduced in your
    post. They’re really convincing and will definitely work.
    Nonetheless, the posts are too brief for starters. May
    you please extend them a little from next time? Thank you for the post.

Leave a Reply to osg777.net Cancel reply

Your email address will not be published.