Comments (6)
I see three ways to fix that:
- put the schema in an
Arc<Mutex<>>
so that it can be updated by the state machine and read by the HTTP server. I'm worried about introducing a mutex in the hot path though, since all new queries will go through reading the schema and query planning - since the HTTP server has a graceful shutdown mechanism, and we can manage the TCP listener separately, we could do as follows:
- the state machine manages the TCP listener. This is necessary because it is not clonable, it is not possible to get it back from warp and hyper, and binding a new one with REUSE_PORT would lose some connections. we might need an extra step, like plugging it into a MPMC queue (potential perf issues introduced here)
- we pass a copy of the receiver at HTTP server creation, along with the
FederatedGraph
instance - whenever there's a new schema, we create a new HTTP server with a new
FederatedGraph
, and we tell the old one to stop through graceful shutdown. As I have measured, creating a new server takes 20ยตs on my machine, and the server is 320 bytes, so it is not a costly operation
- rely on external solutions like systemd and listenfd to restart the server while keeping the listen socket
I'm partial to the second solution, since I have exhaustively explored that particular rabbit hole. Managing the listen socket outside of warp will be useful when we start putting bounds on the number of sessions and rate limiting new connections.
from router.
alternate version for option 2:
- make a hyper service
- avoid the
hyper::Server
and instead use the lower level conn module
with this method we do not need to introduce another queue, but we will need to reimplement the graceful shutdown
from router.
Just bear in mind that it's not restarting the server that is costly. It's draining the requests. That's why we were using shared state before. We would not want to drain the requests to update schema.
from router.
draining the requests was costly because some of them were staying there for a long time, right? Or was there another reason? What was the cost? Memory usage?
from router.
Draining requests is costly due to timeouts. During this time we cannot serve new requests right?
from router.
as said in the call earlier, with #5 we can accept new connections using the new schema right away, we don't need to wait for previous connections to be drained
from router.
Related Issues (20)
- Add new metric for the "real" Router processing time HOT 3
- Add configuration option for `events.subgraph.request|response|error` to target only specified subgraphs
- propagate tracing headers to coprocessor calls HOT 1
- Adding a field changes the returned value of another (@requires directive with arguments involved) HOT 1
- Reducing the configuration schema file
- Introspection query doesn't return latest schema changes when query plan is being persisted on Redis HOT 6
- `request.body.operaton_name` is empty even `query` contain named operation
- Send response errors only to coprocessor
- Unable to remove the Apollo-Expose-Query-Plan with header propagation remove regex HOT 1
- telemetry: add selectors for errors to be able to match on a specific error
- Remove `experimental_when_header` once advanced telemetry features are part of a release
- Add support for response status code in rhai
- Allow `print` or `log_error` to log JSON objects HOT 1
- Update OTEL trace_id value from a request header HOT 9
- Have an option to enable TCP connection details in tracing. HOT 2
- Conditional apply safelisting with operation limits
- Propostal: Injection of state into plugin init
- docs: broken link for "tech notes" HOT 3
- Rust v1.78.0 router-bridge startup panic HOT 1
- trace_id check to accepts dashes as UUID format HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router.