Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/jobs/mef/mef_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Mef
class MefJob < ApplicationJob
attr_accessor :webhook_url, :api_request_id, :mef_credentials

queue_as :mef
retry_on MefService::RetryableError

after_discard do |job, exception|
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/webhook_callback_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class WebhookCallbackJob < ApplicationJob
queue_as :webhook_callback

def perform(api_request_id, webhook_url, payload)
payload_with_api_request_id = payload.merge({api_request_id:})
uri = URI.parse(webhook_url)
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious how you landed on 15 rather than 10 or 20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing value was 5, and I figured that (if I want all connection attempts to succeed immediately) I'm adding 10 new possible threads that might need a DB connection (5 single-threaded workers for the MeF jobs, 1 5-threaded worker for the callbacks).

I'm not actually sure of myself here (maybe the webhook callback worker actually only needs one db connection, since the job doesn't use the db and therefore the only need is for the worker to claim & execute jobs?) but that was my reasoning, faulty or not.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default: &default
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 15 } %>


development:
Expand Down
14 changes: 12 additions & 2 deletions config/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ default: &default
- polling_interval: .1
batch_size: 500
workers:
- queues: "*"
- queues: mef
# We are constrained by MeF to 5 concurrent connections, so we use a limit of 5 single-threaded workers
threads: 1
processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %>
processes: 5
polling_interval: 0.1
- queues: webhook_callbacks
# We want our callbacks to not be blocked by each other, but we know they are threadsafe so we use a multi-threaded
# worker with the same number of threads as there are mef queue workers (in case they all trigger webhooks simultaneously)
threads: 5
processes: 1
polling_interval: 0.1

development:
Expand All @@ -14,5 +21,8 @@ development:
test:
<<: *default

demo:
<<: *default

production:
<<: *default
17 changes: 16 additions & 1 deletion db/queue_schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
ActiveRecord::Schema[7.1].define(version: 1) do
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 1) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"

create_table "solid_queue_blocked_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
Expand Down