Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Dec 3, 2024
1 parent 9887bac commit 9611dc5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,35 @@ the `AWS_PROCESS_BEANSTALK_WORKER_REQUESTS` environment variable to `true` in
the worker environment configuration. The
[SQS Daemon](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html#worker-daemon)
running on the worker sends messages as a POST request to `http://localhost/`.
The aws-sdk-rails middleware will forward each request and parameters to their
The ElasticBeanstalkSQSD middleware will forward each request and parameters to their
appropriate jobs. The middleware will only process requests from the SQS daemon
and will pass on others and so will not interfere with other routes in your
application.

To protect against forgeries, daemon requests will only be processed if they
originate from localhost or the Docker host.

#### Running Jobs Async
By default the ElasticBeanstalkSQSD middleware will process jobs synchronously
and will not complete the request until the job has finished executing. For
long running jobs (exceeding the configured nginix timeout on the worker) this
may cause timeouts and incomplete executions.

To run jobs asynchronously, set the `AWS_PROCESS_BEANSTALK_WORKER_JOBS_ASYNC`
environment variable to `true` in your worker environment. Jobs will be queued
in a ThreadPoolExecutor and the request will return a 200 OK immediately and the
SQS message will be deleted and the job will be executed in the background.

By default the executor will use the available processor count as the the
max_threads. You can configure the max threads for the executor by setting
the `AWS_PROCESS_BEANSTALK_WORKER_THREADS` environment variable.

When there is no additional capacity to execute a task, the middleware
returns a 429 (too many requests) response which will result in the
sqsd NOT deleting the message. The mesagge will be retried again once its
visibility timeout is reached.

#### Periodic (scheduled) jobs
Periodic (scheduled) jobs are also supported with this approach. Elastic
Beanstalk workers support the addition of a `cron.yaml` file in the application
root to configure this. You can call your jobs from your controller actions
Expand Down

0 comments on commit 9611dc5

Please sign in to comment.