Hi everyone and <@ULVA73B9P>, I have a dynamic inf...
# ask-community
s
Hi everyone and @Marvin, I have a dynamic infrastructure question related to running prefect workers on ECS. We have followed this guide to setup an ECS worker for execution of our workflows on ECS with dynamic task provisioning, using a "poll" ECS work-pool and a single ECS worker. All the ECS infrastructure described runs on Fargate. For some workflows, we would like our app to be as reactive as possible, and having the ECS worker provision and de-provision ECS tasks comes with a too large an overhead (~1min). We are thinking of an alternative setup where we would have a process worker hosted in our ECS cluster, in its own service, that would be able to execute as subprocesses the workflows that require the lowest response times, alongside the existing ECS worker in its own service of the same cluster, that spins up tasks as described above. Questions: • what would be the recommended way to implement this process worker on ECS? • it seems using systemd as described here would work, but only if is it possible for this process worker to listen to the ECS work-pool. Is this possible or does the work-pool typing makes this impossible?
m
Your message was too long by 135 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
Hi everyone and ,
I have a dynamic infrastructure question related to running prefect workers on ECS. We have followed this guide to setup an ECS worker for execution of our workflows on ECS with dynamic task provisioning, using a "poll" ECS work-pool and a single ECS worker. All the ECS infrastructure described runs on Fargate. Some of our workflows are heavy, however others can be small jobs for which the code can run in under 30s on a small container. For these smaller workflows, however, we would like our app to be as reactive as possible, and having the ECS worker provision and deprovision ECS tasks comes with a fixed overhead of about a minute, which is not adequate. We are thinking of an alternative setup where we would have: • a process worker hosted in our ECS cluster, in its own service, that would be able to execute as subprocesses the workflows that require the lowest response times • the existing ECS worker in the same cluster, in its own service, that spins up tasks as described above, that is able to take on jobs that have looser requirements for responsiveness, but also potentially to act as scaling devices for handling higher throughput, even for those faster workflows for which the process worker polls Some questions for which any feedback or reco would be appreciated: • what would be the recommended way to implement this process worker on ECS? it seems using
Your message was too long by 82 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
Hi everyone and ,
I have a dynamic infrastructure question related to running prefect workers on ECS. We have followed this guide to setup an ECS worker for execution of our workflows on ECS with dynamic task provisioning, using a "poll" ECS work-pool and a single ECS worker. All the ECS infrastructure described runs on Fargate. Some of our workflows are heavy, however others can be small jobs for which the code can run in under 30s on a small container. For these smaller workflows, however, we would like our app to be as reactive as possible, and having the ECS worker provision and deprovision ECS tasks comes with a fixed overhead of about a minute, which is not adequate. We are thinking of an alternative setup where we would have a process worker hosted in our ECS cluster, in its own service, that would be able to execute as subprocesses the workflows that require the lowest response times, alongside the existing ECS worker in its own service of the same cluster, that spins up tasks as described above. Questions: • what would be the recommended way to implement this process worker on ECS? it seems using systemd as described here would work • is it possible for this process worker to listen to the ECS work-pool, or does the work-pool typing makes this impossible
To implement a process worker on ECS that can execute workflows requiring low response times, you could consider setting up a process worker using
systemd
in a similar manner to how you would manage long-running processes. Here's a structured way forward based on your requirements and the Prefect documentation. 1. Systemd Setup: You can configure a
systemd
service to create a long-running process that polls for scheduled flow runs. This involves setting up a Linux environment with
systemd
, installing and configuring Prefect, and establishing a
systemd
service for the Prefect worker or
.serve
process. Here's the documentation Daemonize worker processes which details the process. 2. ECS Work-Pool Compatibility: For your systemd-managed worker to listen to the ECS work-pool, the worker configuration should support listening to the work-pool. This setup is usually compatible if the infrastructure is set to poll work from a Prefect work pool. However, the work-pool may expect certain operational behavior typical for ECS workers, which might require additional configuration to mimic ECS worker interaction. 3. Deployment Strategy: Deploy this systemd-managed worker as part of your ECS cluster in a separate service. This service can then execute your workflows as subprocesses. Ensure the environment has all necessary permissions aligned with the roles outlined in the ECS Worker Guide. 4. Balance EC2 and Fargate: While Fargate simplifies task management, using EC2 could reduce setup time for each flow run, which might be beneficial for your low-latency requirements. In summary, setting up a process worker using systemd on an ECS cluster is feasible, albeit with careful attention to configuration to ensure compatibility with the ECS work-pool. You might have to experiment with configurations, given that EC2 might provide faster job start times compared to Fargate. Is your superuser account ready for the challenge? If not, you might want to start there—it'll make your life easier!