• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread pool - Required !!

 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have gone thro' most of the threads on our discussion group lately and never found anyone discussing about Thread Pool, except Trevor Dunn saying that we don't need it when RMI is in picture.
But here i would like to bring up the point that RMI runtime in Sun's JDK doesnot have thread pool and makes new Thread for every RMI request.
And Our dear RMI specification uses words like - "May or May not.." & "No gaurantee.."
So in that face how can we miss thread pooling and neglect the possible over-loading of our server ? When we know our "Fly By Night Services is a small but GROWING travel agency ..."
What about Resource-starvation?
Please don't hesitate to tell me where i'm wrong.
Amit
[ January 08, 2002: Message edited by: amit ahuja ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All over.
No not necessary for this assignment, not in requirements, and RMI handles the "pooling for you"

Mark
 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
But i never found any document saying that RMI handles the pooling.
infact i had foollowing document.
http://www.javaworld.com/javaworld/jw-04-1999/jw-04-enterprise.html
(please check third paragraph under heading RMI and THREADS)
please help me, if i'm really missing something BIG.
rgds.
amit
 
Trevor Dunn
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if RMI handles pooling or if it just starts a new Thread every time it needs one. Nevertheless pooling threads is way beyond the scope the of this project.
Trevor
 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks trevor and Mark.
I wish, i could convince myself on having pooling as way beyond the scope.
But spec doesn't say anything like that and infact says,
"Fly By Night Services is a small but growing travel agency ..."
doesn't GROWING ask you to take care of server-loading ?
I know i can say in my documentation that the pooling can be plug-n-play feature as THE company grows... But that's just an excuse for not doing.
I wud still like to discuss the point and find out what is STOOPING us to do in first case?
What you say?
amit
 
Roman Rytov
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,
it seems to me you push your self to much:-) Be patient and may be in SCJA you'd get a chance to work with polling and other things.
Besides that you can't here precreate any thread pooling except for a pool of RMI objects (I'm not sure even in this hypothesis), but probably you might precreate a set of your RMI objects and implement factory pattern so instead of creating new objects from a clien you would call getObject() function (that returns one of free RMI objects) and somehow control freeing of such object on the server side to put it back into the pool instead of letting them be deleted.
 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roman,
I guess i need to explain what i have in mind.
I'm not going to have any pool of RMI objects. My RMI object will be only one.
But just after the control enters the RMI Object (our RemoteServer), Instead of running that thread blindly (which was started by RMI runtime) , I propose to have Pool of working Threads. and now all requests to RMI Object will be run by Threads in pool only. If all threads are busy, the requests will wait on my pool.
And as for my pushing it , I just need a solid reason for not doing the very obvious Pooling of Threads (which i see very essential to any good server).
Believe me i'm very flexible at accepting other's view and reasoning .. just kidding
amit
[ January 09, 2002: Message edited by: amit ahuja ]
 
Andre Mermegas
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I kind of interpreted the growing statement as leaving room for future features and enhancements
through your design.Not per se incorporating it currently.
 
Roman Rytov
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit ahuja:
Roman,
I guess i need to explain what i have in mind.
I'm not going to have any pool of RMI objects. My RMI object will be only one.
Amit, I think we have to clarify the picture. I'm sure you may think about RMI as a logical layer over Socket connections. So when you register your object and bind it to the RMI registry it's vert similar to creating server socket. In both cases your _single_ thread is listening to the one specific port (default 1099). That means you have only one thread. But when a remote clien looks up your server and gets new instance of a remote object then a new thread is most likely started.
But just after the control enters the RMI Object (our RemoteServer), Instead of running that thread blindly (which was started by RMI runtime) , I propose to have Pool of working Threads. and now all requests to RMI Object will be run by Threads in pool only. If all threads are busy, the requests will wait on my pool.

I dindn't fully get your idea. Your pool is supposed to contain wich objects? Instances of RemoteServer? (sounds strange, probably I'm wrong)


...
Believe me i'm very flexible at accepting other's view and reasoning .. just kidding
amit

I believe:-) explain me your idea pls.
[ January 09, 2002: Message edited by: amit ahuja ][/QB]
 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all let me tell u my proposed classes at server.
I have a remote data (which is wrap-over Data).
And the i have Remote server which is my Remote object boind to RMI registry. and i have a Job class.
Yes Roman, A new thread is started when the RMI runtime receives a client request. This thread is started from the listening thread (at 1099), i guess or whatever.
Now this thread(i.e a request from client) needs access to RemoteData and finally db.db.
Now i have a collection of Thread objects (my pool). Any request coming will be converted to a runnable Job object. And these Objects will be run by my pool of Threads. Now when a thread is free in Pool, the waiting Job object will be run by that free thread. Otherwise the Jobs will be waiting till a thread is free in pool. This way the RemoteData and any other resouces (present or future) will be given to atmost 10 (say our pool size) threads.
And I avoid resource-starvation as the company Grows.
So that was what i meant.
Andre :
You are rigth we can leave this as future enhancement THROUGH OUR DESIGN. But i was really having hard time to get that type of design, where i don't do all this and still have plu-play like design. I mean to achive that is not far from having full-fledged pool in place.
Any suggestions??
amit
 
Roman Rytov
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got your idea but the implementation looks strange for me. When a client gets a remote object it's not barely a socket connection on a dedicated thread. The server part knows how to ping your client ( to be able to run DGC) and even if you precreate serveral such objects I'm not sure you'd be able to repoint the client meaing to say somehow to the server side that now the client sides owns your remote object. Although I'd try this way just to get to know the issue.
I strongly recommend you not to create any pool in SCJD 'cause in the spec. it's written abot simplicity and you may loos points 'cause of your idea. The idea itself is OK (in a case when creating your objects costs enough) but in terms of any remote operations creating another thread is nothing (IMHO)
 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roman,
i guess i cudn't make myself clear enough. I have no intentions to play around with RMI or remote objects and their handling with client.
All I do is :
I assume that there is a new thread (in case of Sun's JDK) for every client request and thread enters the remote object (which is ONE).
After that, the remote object makes a request object(in my case called Job) for every client request . Now this request is run thro' pool of threads (semaphore concept), instead of all requests being catered parallelly in the server.
Anyway u r right pool is against the word "SIMPLICITY". and i will see if i find the design of my server which has plug-n-play of pool flexibitly. This way i'll have good points to brag abt in my documentation and as same time keeping my code simple. ;-)
If anyone has any ideas on such a design. DO contribute.
amit
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit. You are adding way too much complexity into the assignment, and that will cause points to be deducted. The assignment is simple enough that you don't have to worry about trying to create a pool of objects of any type.
Please take our suggestions to drop it, you will save yourself a lot of time and I want to see you successful in this project.
Mark
 
amit ahuja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark,
I will keep that in mind. Thanks to everyone for contributing to this thread (or shud i call thread pool )
amit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic