Giter Site home page Giter Site logo

Comments (6)

Geal avatar Geal commented on May 23, 2024

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.

Geal avatar Geal commented on May 23, 2024

alternate version for option 2:

with this method we do not need to introduce another queue, but we will need to reimplement the graceful shutdown

from router.

BrynCooke avatar BrynCooke commented on May 23, 2024

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.

Geal avatar Geal commented on May 23, 2024

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.

BrynCooke avatar BrynCooke commented on May 23, 2024

Draining requests is costly due to timeouts. During this time we cannot serve new requests right?

from router.

Geal avatar Geal commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.