IBM Cloud Code Engine: Stateful Apps and Sticky Sessions, Scaling Issues

288 views Asked by At

My first post on stackoverflow; here goes!

I just discovered IBM Code Engine and am excited to try it out! I tried deploying a docker image of mine this weekend, though I'm having some issues with scaling. Before getting to the scaling issues I have some questions about IBM Cloud Code Engine in general, with my interactive application in mind:

  1. Stateful Applications: The application I'd like to deploy is stateful. Does IBM Cloud Code Engine support stateful apps out of the box?
  2. Sticky Sessions: Since my application is stateful, the goal is to have a user and all their associated actions stay within the same container. E.g., if a user is in container 1 and clicks a button that executes server-side code I would not want that code executed in container 2; it should be in container 1. Does IBM Cloud Code Engine support this out of the box?
  3. Ephemeral Storage: I see in the documentation that ephemeral storage (i.e., disk space) can be set, though I do not see the ability to modify this in the console. Am I missing something? Alternatively, does more vCPU & memory imply more disk? I personally prefer the CLI for the container registry, and the console for code engine itself.

Note that I have these questions whether concurrency per instance is 1 or more users.

Notes on scaling: I successfully deployed my application and it looked as expected. However, as the only user I saw multiple instances running rather than one (2, sometimes 3 instances). When I opened another browser and logged in as another user the same thing happened. Double or triple the instances needed were running. Can someone advise? Going back to my questions above, my hope is that interacting with the app does not trigger additional instances.

I can provide a simple Dockerfile and app code if helpful.

1

There are 1 answers

4
S. Moser On
  1. Generally speaking the answer is yes, although it depends how you define stateful and where you store the state. Example: storing the state in an COS/S3 bucket is possible, storing it in an NFS mount not at the moment
  2. Unfortunately no. The underlying Knative OSS technology does not support sticky sessions yet, although the open source community is working on it, so it might be coming.
  3. This is not currently supported in the UI, but in the CLI you can specify ibmcloud ce app create --ephemeral-storage as a param
  4. Scaling: That depends on how you have defined your scaling criteria. When you create your app, in the Runtime settings section you can specify a concurrency value. That determines the value how many threads/requests one instance will process in parallel. If the value is set to 1, and you have three browser tabs open sending requests, Code engine will scale up to (at least) three instances (e.g. when the scale target is 70% of compute capacity, we’d spin up to 4). If the value is set to 100, one instance will handle 100 parallel requests and the scale out will only occur if you get 101 requests. It is independent of how many users send these requests.