styx icon indicating copy to clipboard operation
styx copied to clipboard

Route to alternative origin when a sticky origin is not available

Open mikkokar opened this issue 6 years ago • 3 comments

The problem

I believe Styx is supposed to choose a different origin if one indicated by a sticky session cookie is no longer available.

But this is not happening. Instead says comes back with a BAD_GATEWAY etc error code.

Detailed description

The following, modified, StickySessionSpec test will fail:

  test("Routes to new origin when the origin indicated by sticky session cookie is no longer available.") {
    server1.stop()

    val client: StyxBackendServiceClient = newHttpClientBuilder(backendService.id)
      .loadBalancer(stickySessionStrategy(activeOrigins(backendService)))
      .build

    val request: LiveHttpRequest = get("/")
      .cookies(requestCookie("styx_origin_app", "app-01"))
      .build

    val response = Mono.from(client.sendRequest(request)).block()

    response.status() should be(OK)
    response.cookies() should have size 1
    val cookie = response.cookie("styx_origin_app").get()

    cookie.value() should be("app-02")

    cookie.path().get() should be("/")
    cookie.httpOnly() should be(true)
    cookie.maxAge().isPresent should be(true)
  }

mikkokar avatar Jun 14 '19 13:06 mikkokar

To clarify, when you say the test was modified, you mean fixed? That is, because the previous implementation seemed to stop server 1, but then make a request for server 2 (which tests nothing)?

Anyway, I agree, we are supposed to switch to a new origin, otherwise the user would have to clear their cookies to continue using the site.

However, we will want to ensure we make a good attempt to retry the bad server, because when we switch, the user will lose all their current session data*, so we don't want to do it too hastily.

* Typically one would use sticky-sessions if the servers do not share session data.

kvosper avatar Jun 14 '19 16:06 kvosper

Solution could be to remove sticky origins.

bestokes avatar Oct 04 '19 09:10 bestokes

Let's consider removing this feature.

mikkokar avatar Oct 04 '19 09:10 mikkokar

Closing all issues over 3 years old. New issues can be created if problems are still occurring.

kvosper avatar Jan 11 '24 11:01 kvosper