Replies: 5 comments 4 replies
-
This is a good but also hard question to pin down. Can you give specifics on
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Right now there isn't anything built into Xpublish itself for rate limiting. Since it's FastAPI under the hood, it's possible to use it's libraries like fastapi-limiter to do rate limiting by injecting a limiter into route dependencies. rest = xpublish.Rest(...)
app = rest.app
@app.on_event("startup")
async def startup():
redis = redis.from_url("redis://localhost", encoding="utf-8", decode_responses=True)
await FastAPILimiter.init(redis)
for route in app.routes:
if route.path.startswith("/datasets"): # or another check to see if a route is one that should be limited
route.dependencies.append(Depends(RateLimiter(times=2, seconds=5))) I'd like to continue expanding the plugin system, so that we could have plugins modify other routes to support things like limiting, but I wanted to see what uses folks would have before taking a swing at it. |
Beta Was this translation helpful? Give feedback.
-
Rate limiting is also something that is often well addressed by your reverse-proxy server, which will save Xpublish/FastAPI from needing to make any decisions. For instance if you're deploying with Kubernetes and using ingress-nginx it has a lot of fine grained controls for limiting. |
Beta Was this translation helpful? Give feedback.
-
thank you for your quick answers. In production, xpublish runs behind a nginx reverse-proxy. I am a beginner in server deployment.
and the plugin does a lot of So regarding the memory management: Do I understand correctly that when I open a file with xarray on the server side, the chunks are decompressed first independently of how I send them to the clients? Even if the compressor do not change (not my use case)? I assume that it is most performant to send compressed chunks because this reduces traffic. Would you agree? |
Beta Was this translation helpful? Give feedback.
-
I decided to use the nginx rate limiter. After experimenting a bit with the So I decided to set
On the server I use dask and target at chunks with size 100MB. In my test case, I open a huge netcdf dataset on the server, uncompressed and kerchunked. The client (with 4 threads) directly writes a subset of the data to a disk.
The speed is 3MB/s compressed (12MB/s uncompressed). However, there are open questions from my previous post which influences this performance. |
Beta Was this translation helpful? Give feedback.
-
Hi,
if a user wants to retrieve a bigger part of a dataset which includes multiple chunks, they are requested all at once. Depending on the processing on the server side, this leads to high memory consumption which probably blocks all further requests. Is it possible to limit the requests per user by adapting the configuration on the server side?
Best and thanks a lot,
Fabi
Beta Was this translation helpful? Give feedback.
All reactions