Hi Ron,

On 18-Dec-06, at 5:05 PM, Rol El wrote:

>
> Hey folks. Since there is some confusion on my library, let me put out
> some code.
>
> Lets say I have a libWebData.so, and i have python bindings to it. The
> way I init and use it is:
>
> webDataInit(myCallback)
> webDataGetEmployeeDetails(ID=100) # This call goes into libWebData.so
> which spawns a pthread and immediately returns
>
> Then after some time, you get a callback.. the library calls something
> like:
> myCallback(dataID=100, {'name':'TG', 'age':'2'})
>

OK, this makes sense.

>
> Now the problem is if i make this sequence synchronous in my library,
> i'll DoS myself in TG. The cherrypy pool only has 10 threads. So, each
> thread is waiting on this data which can take however long.. So, if 10
> people connect at once and are waiting for the synchronous call to
> finish, no one else can access the webserver even though they are  
> doing
> nothing related to the data. As you can see, increasing the thread  
> pool
> will also be useless, because it wont server the actual purpose of
> resource throttling then, and you WILL get DoS'ed under a load of  
> users
> == thread_pool_size.
>
> So, one solution can be to order cherrypy to remove the current thread
> from the thread pool until the callback is called, and in which case
> the callback does something in it to put itself back into the thread
> pool or something. I have no clue if there is a way for this.. If  
> there
> is, how do i implement a timeout in the case where the callback didn't
> come back forever?
>
> Igor, your solution 1, and 2 involve the threads waiting, and this
> means if i have 10 threads waiting, i'll DoS myself due to the above
> described thread_pool problem.

Yes, but the question is: what are you trying to achieve. As far as I  
can
see you have 2 options:
- Make the asynchronous call synchronous, so that the controller only
returns after myCallback is run. The user's browser waits for the  
response
all this time. You inevitably DoS yourself as you say.

- Keep the call asynchronous, the controller method returns right away,
so that the user gets a template telling him that the request has been
submitted, and some sort of JS status indicator. The status indicator
will use pollilng on a regular interface (10 seconds) to check if the
the request has returned. You don't DoS yourself.

Based on what you said above I think the section section makes more
sense in your case.

Igor



--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to