storj / drpc

drpc is a lightweight, drop-in replacement for gRPC
MIT License
1.49k stars 49 forks source link

migration steps #38

Closed newhook closed 1 year ago

newhook commented 1 year ago

The migration steps in the blog post are:

  1. Release and deploy new server code that understands both gRPC and DRPC concurrently. With DRPC, this was a breeze since all of our application code could be used identically with both, and our ListenMux allowed us to do both from the same server port.
  2. Once all the servers and Nodes were updated, release and deploy new clients that spoke DRPC instead of gRPC.
  3. Once all of the old clients were gone, we removed the gRPC code.

I was just experimenting with that, and all that works well. Except I realized that to use the migration the drpc dialing needs to be switched to send the header.

nc, err := drpcmigrate.DialWithHeader(ctx, "tcp", addr, drpcmigrate.DRPCHeader)

It seems like after grpc is gone ideally you'd also want to switch this back to a plain headerless dial, but won't doing that require taking down all servers and clients at the same time, as the headerless dial is incompatible with the listen multiplexer?

zeebo commented 1 year ago

You don't need to take down everything at the same time. Once all the clients are updated to use the header dial, you can then change the server listenmux default listener to also serve DRPC because no clients are expecting gRPC anymore. Then, once all the servers are updated, you can change all the clients to no longer send he header. Then you can remove the listenmux entirely if you want. Basically the same steps in reverse.

newhook commented 1 year ago

Thanks I’ll try that.

newhook commented 1 year ago

Ok, I tested the migration process, and yes, it works just as you say.

Basically you run the drpc server on the routing listener mux and the default mux.

return s.Serve(ctx, lisMux.Route(drpcmigrate.DRPCHeader))
    ^^ this looks for the drpcheader and forwards all requests to drpc.

return s.Serve(ctx, lisMux.Default())
    ^^ this forwards unconditionally all requests to drpc, and was originally attached to grpc.