Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State machine in kubernetes cluster #1165

Open
akki1306 opened this issue Sep 14, 2024 · 1 comment
Open

State machine in kubernetes cluster #1165

akki1306 opened this issue Sep 14, 2024 · 1 comment
Labels
status/need-triage Team needs to triage and take a first look

Comments

@akki1306
Copy link

I want to run a spring state machine in an AKS cluster with multiple pods running the same application instance. The state machine is long-running and might take over 12 hours to complete. State machine configuration looks like the below with internal state transition every 15 minutes and triggers state change if required conditions are met in the internal state action.

I am using state machine service along with JPA persister.

How do I ensure that the long-running state machine starts running on another pod if any one of the pod crashes or restarts ?

transitions
.withExternal()
.source(S1).target(S2).event(S1_to_S2).and()
.withInternal().timer(Duration.ofMinutes(15)).action(a -> checkAndTriggerEvent());

Untitled (5)

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Sep 14, 2024
@mehmetsalgar
Copy link

First of all, let me tell you that I have no affiliation with Spring State Machine or Development, so please took what I write as a certain grain of salt...

Spring State Machine is great for many use cases but I am not sure it fits your use case, as much as I know Spring State Machine has no concept of unit of work, so several Spring State Machines would coordinate for fulfilment of your scenario, so it will pick and continue the work of another instance if that other instance, in your case k8s pod, terminated...

That level of cluster coordination are provided from other Frameworks like

Pekko Finite State Machine

Pekko Cluster Sharding

I explained in one of my Blogs how the Cluster Sharding and State Machine works for Pekko

Cluster Sharding with State Machine

may be this solutions fits better to your requirement, I hope this helps..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/need-triage Team needs to triage and take a first look
Projects
None yet
Development

No branches or pull requests

2 participants