Jump to content

SpringBoot question


Hindhustani

Recommended Posts

46 minutes ago, dasari4kntr said:

spring uses a combination of thread-safety through configuration and AOP... to ensure that singleton beans are thread-safe and can handle multiple requests simultaneously.... the thread-safety through configuration is achieved by allowing each thread... to have its own copy of the thread-local variables and AOP allows spring to add synchronization to specific methods of a singleton bean... so that multiple threads can safely access the bean at the same time....

Synchronization will add slowness correct? . But since REST API needs to be stateless. Only option is have more micro service containers spin up so each will have separate Jvm?

Link to comment
Share on other sites

5 minutes ago, Hindhustani said:

Bro , singletons per jvm there will be only one , even if there are thread pools at one layer it may speed little bit but when it comes to actual processing other thread have to wait until current thread finished ? @ramudu @dasari4kntr

yes , think each layer has its own request queue (sorry I mention Stack in last answer , it is LIFO )  

Link to comment
Share on other sites

17 minutes ago, Hindhustani said:

Synchronization will add slowness correct? . But since REST API needs to be stateless. Only option is have more micro service containers spin up so each will have separate Jvm?

stateles is where you don't maintain any request /response specifc state in your controller / service layer , your code take request , process it and send the response back and forget about it unlike old servlets container based sessions where you can store user / request / session related information and access that in next request coming from same user    

Link to comment
Share on other sites

2 minutes ago, ramudu said:

yes , think each layer has its own request queue (sorry I mention Stack in last answer , it is LIFO )  

Thanks for the details bro. You work in Java,,  TL or  manager etc? How long ? 

Link to comment
Share on other sites

2 hours ago, Hindhustani said:

Spring boot @controller @service @repository stereotype are singleton and stateless , and thread safe , correct? If so any thread safe and singleton class are in slow processing? If so how does millions of  reaquests are processed and handled ? 
  Let’s say if there are 100 requests coming to REST API method in controller class , since it is singleton in nature only one request handle at a time ? 
 

or my understanding is incorrect that 100 threads meaning 100 instance of controller class created and each request handled by each controller instance ? 
 

@dasari4kntr @csrcsr  @Vaampire

 

https://www.baeldung.com/spring-singleton-concurrent-requests

I believe this is what you are looking for. State will be shared ( class level variables) and hence the importance of being stateless in case of Singleton classes. 

 

 

 

 

 

Link to comment
Share on other sites

On 1/22/2023 at 11:18 PM, ramudu said:

 coding chesi chala kalam ayindi bro  #$1

Super bro. But how you remember the knowledge. You do code reviews? . Just asking. Even if we read any new tech without hands on. Don’t remember for long time. Are you architect . I’m in mixed role of every thing.  But companies required experts in one other field. How do you keep up your skills without hands on.

Link to comment
Share on other sites

42 minutes ago, Hindhustani said:

Super bro. But how you remember the knowledge. You do code reviews? . Just asking. Even if we read any new tech without hands on. Don’t remember for long time. Are you architect . I’m in mixed role of every thing.  But companies required experts in one other field. How do you keep up your skills without hands on.

Yeah I am part of architect team , bro keep visiting dev.to ,  medium etc ,  read those blogs and discuss with your colleagues or friends also visit websites like dzone to know the technology trends. Develope small side projects , in few months you gain good understanding 

Link to comment
Share on other sites

11 minutes ago, Hindhustani said:

Did candidate gave correct ans?

nope..

aa candidate konchem weak vunnadu…

micro services paina work chesa ani cheppadu…api gateway gurinchi adigithe cheppalekapoyadu…

sorting based custom dictionary ani coding question ichha..cheyyaleka poyadu…

Link to comment
Share on other sites

13 minutes ago, dasari4kntr said:

nope..

aa candidate konchem weak vunnadu…

micro services paina work chesa ani cheppadu…api gateway gurinchi adigithe cheppalekapoyadu…

sorting based custom dictionary ani coding question ichha..cheyyaleka poyadu…

interview questions ki actual work entha match vuntundi anna

  • Upvote 1
Link to comment
Share on other sites

19 minutes ago, alpachinao said:

interview questions ki actual work entha match vuntundi anna

yup..anduke..i dont rely on questions and answers...question and asnwers are just to see his communication and behaviour...

i always give simple coding questions...i ask..them write code...

thats my main assessment...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...