Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBS access frequency control #600

Open
yuyiguo opened this issue Apr 15, 2019 · 8 comments
Open

DBS access frequency control #600

yuyiguo opened this issue Apr 15, 2019 · 8 comments

Comments

@yuyiguo
Copy link
Member

yuyiguo commented Apr 15, 2019

@vkuznet @belforte @amaltaro @bbockelm
DBS servers was frequently crushed for a period of time as described in #595. The root cause was a client made hundreds even thousands of threads against DBS. The risk behavior affected entire DBS clients. In order to prevent this happens again, We need to put a limit on how many calls a client can make per minute? Should the limit based on DN? Should we distinguish between individual user vs production system? Where should the limit be front end or backend?

@vkuznet
Copy link
Contributor

vkuznet commented Apr 16, 2019

I posted my response in another ticket, but for completeness it should go here:

For apache we can use mod_evasive or mod_throttle, while for DBS backend I didn't find explicitly cherrypy solution and we should probably write our own. But for Flask we can use
http://flask.pocoo.org/snippets/70/

If we'll need to write our own throttling for DBS (WMCore in general) it should track clients based on DN's (to allow catch bulk requests from distributed clients), we can whitelist production system DNs.

@yuyiguo
Copy link
Member Author

yuyiguo commented Apr 16, 2019

@vkuznet
If we can do this in the front end, it would be better. All the requests get into back ends, it could be a bit late to stop it
Yuyi

@bbockelm
Copy link
Contributor

You probably don't really want a rate limiter but rather a concurrency limiter -- no one cares if you do many cheap queries.

We do this in CRAB to prevent users from hitting the service with many queries in parallel:

dmwm/CRABServer@7601be8

It happens on the backend since the resources there are more precious...

@belforte
Copy link
Member

belforte commented Apr 17, 2019 via email

@vkuznet
Copy link
Contributor

vkuznet commented Apr 22, 2019 via email

@belforte
Copy link
Member

belforte commented Apr 22, 2019 via email

@vkuznet
Copy link
Contributor

vkuznet commented Apr 23, 2019

Ok, I ported code from CRABServer into WMCore, see dmwm/WMCore#9158
Once merged I'll make PR for CRABServer.

@yuyiguo , Yuyi you can look at unit test I provided (https://github.com/dmwm/WMCore/blob/7b2ec2a690d03e8066dcc56d182070a0c451c09b/test/python/Utils_t/Throttled_t.py) and implement something similar for DBS. Basically what you need to do is to add an additional decorator to your API method which you'd like to throttle, e.g.

@global_user_throttle.make_throttled()
def throttled_function():
    "Test function for throttled"
    # put here any logic you want

@vkuznet
Copy link
Contributor

vkuznet commented Apr 23, 2019

@belforte , Stefano, here is relevant PR for CRABServer: dmwm/CRABServer#5880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants