Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Are sequence that send http requests and will be called HttpServlet.service the same?  RSS feed

 
hiroyuki sano
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If same client pc send two http requests to servlet container, are sequence that send http requests and will be called HttpServlet.service the same?
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No

HTTP is built on top of TCP. TCP doesn't guarantee that 2 requests sent from the same client will be received by the server in the order they were sent.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There would be two requests from your browser to your server. This 2 requests will be processed concurrently by 2 threads and they both will be executing the service method at the same time.
 
Tim Moores
Saloon Keeper
Posts: 3881
91
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if the requests are sent simultaneously -assuming that's the question, I'm not sure- it's unlikely that they would arrive simultaneously at the server after traveling over the network. And even if they arrive simultaneously, it's not a given that they will be processed concurrently.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Even if the requests are sent simultaneously -assuming that's the question, I'm not sure- it's unlikely that they would arrive simultaneously at the server after traveling over the network. And even if they arrive simultaneously, it's not a given that they will be processed concurrently.


If they arrive simultaneously, then chances are very high that they will run concurrently unless server is experiencing thread starvation.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a mighty big if!
 
Anurag Verma
Ranch Hand
Posts: 170
Hibernate Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
agreed with Bear. & in short, the answer is...THERE IS NO SUCH GUARANTEE.
 
Palak Mathur
Ranch Hand
Posts: 343
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiroyuki sano wrote:If same client pc send two http requests to servlet container, are sequence that send http requests and will be called HttpServlet.service the same?


There is no guaranteed order in which they will be treated.
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OTH, if you send a request, wait for the response and then send another request after reading the response, then the requests are guaranteed to be recieved in order
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!