0

A Kubernetes novice here.

I have a simple client/server web application for video conversion:

  • The frontend uploads a video via HTTP POST, receives a response with a status check URL
  • The backend starts converting the video in the background
  • The frontend repeatedly polls the status check URL it received.
  • When finished, the frontend downloads the converted video from the URL returned by the status check

Now I want to move the backend into a Kubernetes cluster and am stuck. Obviously, status check and video download requests must go to the same pod as the one that received the original video conversion request, because only that pod has the video data and the background task that converts it. How do I achieve that?

"Back in the day" you used sticky sessions for that, but I understand sticky sessions are a big no-no for modern cloud computing.

Pushing the converted video into a database or a message queue so that it would be available to all pods sounds like horrible overhead.

Is there a nice solution/design pattern for starting a long running backend task in a pod and later retrieving (pulling) its result from the same pod?

The backend is in Spring Boot in case it matters.

3
  • "Pushing the converted video into a database or a message queue so that it would be available to all pods sounds like horrible overhead." - It sound slike the architecture is not really fit for a cloud-native environment. Every pod should be able to serve the client. For querying the status, this should be simple (having, for example, a simple table with the status of the video, and the backend converting the video updates the entry). For storage, therea re solutions that allow shared access to the file once it is created. One is an S3-compliant storage. Another is a shared file system. Commented Sep 15, 2024 at 11:20
  • A shared file system would be a bottleneck if there are many pods. S3-compliant storage is a possibility, but quite an expensive one for what is basically temporary storage. Logically, the whole thing is one request ("convert a video"), it is only split into several HTTP requests to show progress and to avoid HTTP timeouts. Commented Sep 15, 2024 at 12:15
  • 1
    You can always think about things like Server-sent events to update the status to the client. The TCP connection s kept open, and the pod can "push" updates to the client. Commented Sep 15, 2024 at 12:31

1 Answer 1

0

You could build two services:

  • Central service: register / orchestrator.
  • Video processor.

Clients talk to the central service; the processors talk to the central service.

[Client(s)] ---> [Central Service] <--- [Processor(s)]

I'm not sure how you are kicking off actual video processing, but in the pattern I am thinking about the central service would either spark-up a processor, or have a processor inform it that it was doing a new job.

As the processor does its thing, it informs (pushes updates to) the central service.

Clients can request the status of a known job at any time, from the central service, which simply looks up the status info it has for that job.

Yes, the central service is technically a "bottleneck", but there is no reason why it can't be made performant - unless your NFR's are really off the scale?

In terms of coupling, as long as the interfaces are well considered (i.e. simple, clean and elegant) then I don't see why that should be an issue either. Rather than thinking about the 2 services as being isolated microservices that "should" be totally independent from each other, consider the wider solution as just that - a single solution that just happens to have one component that can be scaled-out.

I'm sure there's at least one named design pattern which this is emulating; I don't think it's exactly the Momento pattern; Mediator is for how a set of objects interact, without knowing about each other - again not exactly what I have described above but might be a good one to have in your back pocket.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.