fix: improve flow performance at high-throughput

This commit is contained in:
Ruben Fiszel
2023-10-24 00:11:30 +02:00
parent 83877a3591
commit f3b709857f
14 changed files with 99 additions and 25 deletions
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -67,6 +67,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -1,22 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM completed_job WHERE started_at + ((duration_ms/1000 + $1) || ' s')::interval <= now() RETURNING id",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": [
false
]
},
"hash": "502781c4e2fc692db7a66b850450a1934b2403a5cff0421fe9609f9b99d8ee95"
}
@@ -28,6 +28,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -60,6 +60,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -46,6 +46,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -40,6 +40,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -0,0 +1,22 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": [
false
]
},
"hash": "bb0ee03198bcad69a1777447cf5c42fc22700e3cbf8cd44621a8380536d77552"
}
@@ -42,6 +42,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
@@ -37,6 +37,7 @@
"bash",
"postgresql",
"nativets",
"Nativets",
"bun",
"mysql",
"bigquery",
+1 -1
View File
@@ -194,7 +194,7 @@ pub async fn delete_expired_items(db: &DB) -> () {
let job_retention_secs = *JOB_RETENTION_SECS.read().await;
if job_retention_secs > 0 {
let deleted_jobs = sqlx::query_scalar!(
"DELETE FROM completed_job WHERE started_at + ((duration_ms/1000 + $1) || ' s')::interval <= now() RETURNING id",
"DELETE FROM completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id",
job_retention_secs
)
.fetch_all(db)
+2 -2
View File
@@ -415,7 +415,7 @@ pub async fn add_completed_job<
tx.commit().await?;
#[cfg(feature = "enterprise")]
if !is_flow && _duration > 1000 {
if *CLOUD_HOSTED && !is_flow && _duration > 1000 {
let additional_usage = _duration / 1000;
let w_id = &queued_job.workspace_id;
let premium_workspace = *windmill_common::worker::CLOUD_HOSTED
@@ -1716,7 +1716,7 @@ pub async fn push<'c, T: Serialize + Send + Sync, R: rsmq_async::RsmqConnection
priority_override: Option<i16>,
) -> Result<(Uuid, QueueTransaction<'c, R>), Error> {
#[cfg(feature = "enterprise")]
{
if *CLOUD_HOSTED {
let premium_workspace = *CLOUD_HOSTED
&& sqlx::query_scalar!("SELECT premium FROM workspace WHERE id = $1", workspace_id)
.fetch_one(_db)
+65
View File
@@ -273,7 +273,59 @@ db.address.apply((address) => {
],
environment: [
{ name: "MODE", value: "worker" },
{ name: "NUM_WORKERS", value: "1" },
// { name: "METRICS_ADDR", value: "true" },
{ name: "RUST_LOG", value: "info" },
{
name: "DATABASE_URL",
value: `postgres://postgres:postgres@${address}/windmill?sslmode=disable`,
},
],
logConfiguration: {
logDriver: "awslogs",
options: {
"awslogs-group": "windmill-worker",
"awslogs-region": "us-east-2",
"awslogs-create-group": "true",
"awslogs-stream-prefix": "windmill-worker",
},
},
dockerLabels: {
PROMETHEUS_EXPORTER_PORT: "8001",
},
},
]),
volumes: [
{
name: "dependency_cache",
dockerVolumeConfiguration: {
scope: "shared",
autoprovision: true,
},
},
],
});
const worker_td2 = new aws.ecs.TaskDefinition("worker-3", {
family: "windmill-worker-2",
containerDefinitions: JSON.stringify([
{
name: "windmill-worker",
image: "ghcr.io/windmill-labs/windmill-ee:main",
cpu: 1024,
memory: 1800,
essential: true,
mountPaths: [
{
containerPath: "/tmp/windmill/cache",
sourceVolume: "dependency_cache",
},
],
environment: [
{ name: "WORKER_GROUP", value: "dedicated" },
{ name: "NUM_WORKERS", value: "10" },
{ name: "MODE", value: "worker" },
// { name: "METRICS_ADDR", value: "true" },
{ name: "RUST_LOG", value: "info" },
{
@@ -381,6 +433,19 @@ db.address.apply((address) => {
},
],
});
const service_worker2 = new aws.ecs.Service("service-worker-2", {
cluster: cluster.id,
taskDefinition: worker_td2.arn,
desiredCount: 5,
forceNewDeployment: true,
orderedPlacementStrategies: [
{
type: "binpack",
field: "cpu",
},
],
});
});
module.exports = {