Skip to content

Concurrency throttling provides stable response time when faced with un-predictable concurrency #2463

@robert-s-lee

Description

@robert-s-lee

Exalate commented:

Overview

Microservices and web applications user concurrency is often not predictable. Throttling the concurrency into the database at tested concurrency can stabilize the throughput and response in the face of unpredictability.

Details

Concurrency tests that exceed server's resource capacity worsen's performance. By throttling concurrency at about 75% of the resource's limit, better performance can be achieved. Throttling the concurrency limits the context switching that has a negative effect on the performance.

Results

The graphs below show throughput and response time by

  • varying concurrency from 1 to 8
  • throttling concurrency into the database at 3 and no throttling
  • the blue line represents concurrency throttled at 3
  • the red line represents no throttling

By capping the concurrency into the database, the throughput is capped to that of concurrency=3

chart 2

By capping the concurrency into the database, the response time shows stable 1ms even at high concurrency whereas, without the throttling, the response time gets worse and worse.

chart 1

Test Config

Below script was run varying the concurrency from 1 to 8 on i3 CPU with Linux. The workload was set to 100% read which will stress the CPU. Concurrency of 3 is expected to be the max for this system.

for c in 1 2 3 4 5 6 7 8; do
echo $c
kv -read-percent 100 -duration 20s -concurrency $c 'postgresql://root@localhost:26256?sslmode=disable'
sleep 5
done

haproxy.cfg was setup in two different ways.

default which does not limit concurrency

global
  maxconn 4096

defaults
    mode                tcp
    timeout connect     10s
    timeout client      1m
    timeout server      1m

listen psql
    bind :26256
    mode tcp
    balance roundrobin
    server cockroach1 127.0.0.1:26257 

limit concurrency to 3 into the database

global
  maxconn 4096

defaults
    mode                tcp
    timeout connect     10s
    timeout client      1m
    timeout server      1m

listen psql
    bind :26256
    mode tcp
    balance roundrobin
    server cockroach1 127.0.0.1:26257 maxconn 3

Jira Issue: DOC-146

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions