Files
fn-serverless/vendor/google.golang.org/grpc/Documentation/stickiness.md
Reed Allman 51ff7caeb2 Bye bye openapi (#1081)
* add DateTime sans mgo

* change all uses of strfmt.DateTime to common.DateTime, remove test strfmt usage

* remove api tests, system-test dep on api test

multiple reasons to remove the api tests:

* awkward dependency with fn_go meant generating bindings on a branched fn to
vendor those to test new stuff. this is at a minimum not at all intuitive,
worth it, nor a fun way to spend the finite amount of time we have to live.
* api tests only tested a subset of functionality that the server/ api tests
already test, and we risk having tests where one tests some thing and the
other doesn't. let's not. we have too many test suites as it is, and these
pretty much only test that we updated the fn_go bindings, which is actually a
hassle as noted above and the cli will pretty quickly figure out anyway.
* fn_go relies on openapi, which relies on mgo, which is deprecated and we'd
like to remove as a dependency. openapi is a _huge_ dep built in a NIH
fashion, that cannot simply remove the mgo dep as users may be using it.
we've now stolen their date time and otherwise killed usage of it in fn core,
for fn_go it still exists but that's less of a problem.

* update deps

removals:

* easyjson
* mgo
* go-openapi
* mapstructure
* fn_go
* purell
* go-validator

also, had to lock docker. we shouldn't use docker on master anyway, they
strongly advise against that. had no luck with latest version rev, so i locked
it to what we were using before. until next time.

the rest is just playing dep roulette, those end up removing a ton tho

* fix exec test to work

* account for john le cache
2018-06-21 11:09:16 -07:00

1.4 KiB

Stickiness

With load balancer, each RPC pick a different backend based on the load balancing policy. Stickiness policies try to preserve peers for the duration of a session, so that RPCs with the same stickiness key will be directed to the same server.

Note that there's only "soft" stickiness now, which means RPCs with the same stickienss key could still be sent to different servers. If stickiness is critical for the system, server side application level handling is still necessary.

Stickiness Key

A stickiness key works as the session id. RPCs with the same stickiness key will be assigned to the same backend.

Stickiness key is set as part of the custom metadata.

Enable stickiness

Stickiness can be enabled by setting stickinessKey field in service config.

{
  "stickinessKey": "sessionid"
}

The value sesseionid will be used as the key of the metadata entry that defines the stickiness key for each RPC.

Send RPC with stickiness

To set the stickiness key for an RPC, set the corresponding metadata. The following RPC will be sent with stickiness key session1.

// "sessionid" is the metadata key specified by service config, "session1" is
// the stickiness key for this RPC.
md := metadata.Paris("sessionid", "session1")

ctx := metadata.NewOutgoingContext(context.Background(), md)
resp, err := client.SomeRPC(ctx, req)