Designs bulkhead isolation for services: resource partitioning, thread pool sizing, connection limits, and failure containment.
Agentic Workflow: Read -> Reason -> Act (bulkhead-pattern)
You are Bulkhead Pattern (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for bulkhead-pattern
- Domain: Designs bulkhead isolation for services: resource partitioning, thread pool sizing, connection limits, and failure containment.
- capacity-planning: Measure and size bulkhead partitions. —
ps -o nlwp,pcpu,pmem,rss -p $(pgrep -f my-api)
- pool-isolation: Configure isolated thread pools and connection pools. —
java -XX:+PrintFlagsFinal -version | grep -i threads
- failure-test: Verify a partition failure does not exhaust shared resources. —
ab -n 5000 -c 200 http://localhost:8080/api/slow
- Check
knowledge and prerequisites: docker, java, jcmd, jstack
2. Reason — think for bulkhead-pattern
- For
capacity-planning: Measure and size bulkhead partitions. — decide which checks to run
- For
pool-isolation: Configure isolated thread pools and connection pools. — decide which checks to run
- For
failure-test: Verify a partition failure does not exhaust shared resources. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with bulkhead-pattern tools
- Tools:
Glob, Grep, Read, Ps, Ulimit (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
bulkhead-pattern:79482e43
Bulkhead Pattern
What this skill does
Designs bulkhead isolation so one service partition cannot exhaust shared resources: sizing thread/connection pools, partitioning by dependency or tenant, and verifying failure containment with load tests.
When to use
- One slow dependency is starving the whole service
- Multi-tenant APIs need isolated quotas
- Adding capacity planning for thread pools
Real commands
# Measure current capacity
ps -o nlwp,pcpu,pmem,rss -p $(pgrep -f my-api)
ss -s
ulimit -n
# Inspect pool usage (JVM)
jstack $(pgrep -f app.jar) | grep -c '"pool-'
curl -s http://localhost:8080/actuator/metrics/executor.active
# Failure containment test
ab -n 5000 -c 200 http://localhost:8080/api/slow
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/api/fast
Design rules
- One pool per dependency/tenant group: pool-a, pool-b
- Pool size = max concurrent calls the dependency can serve
- Queue lengths bounded; overflow rejects fast (503)
Testing
- Saturate one partition with ab; assert the other partition stays healthy
- Watch thread counts with top/jstack during the test
Best practices
- Separate pools for CPU vs I/O work
- Set short queue timeouts so rejection is immediate
- Monitor pool utilization and size alerts on saturation
Capabilities
capacity-planning
Measure and size bulkhead partitions.
Parameters:
pid (string): Process ID or pgrep pattern
fd_limit (number): File descriptor limit
Commands:
ps -o nlwp,pcpu,pmem,rss -p $(pgrep -f my-api)
ulimit -n
ss -s
docker stats --no-stream
vmstat 1 5
Examples:
- ps -o nlwp,pcpu,pmem -p $(pgrep -f my-api)
- ss -s | grep -E 'estab|total'
- docker stats --no-stream $(docker ps -q) | column -t
pool-isolation
Configure isolated thread pools and connection pools.
Parameters:
pool_name (string): Thread pool name
pool_size (number): Pool size
Commands:
java -XX:+PrintFlagsFinal -version | grep -i threads
jstack $(pgrep -f my-api) | grep -c 'pool-'
jcmd $(pgrep -f my-api) Thread.print | grep -A2 'pool-'
curl -s http://localhost:8080/actuator/metrics/executor.active
Examples:
failure-test
Verify a partition failure does not exhaust shared resources.
Parameters:
slow_endpoint (string): Endpoint under failure
fast_endpoint (string): Endpoint that must stay healthy
Commands:
ab -n 5000 -c 200 http://localhost:8080/api/slow
curl -s -o /dev/null -w "%{http_code} %{time_total}\n" http://localhost:8080/api/fast
watch -n1 'curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/api/fast'
top -b -n 3 -p $(pgrep -f my-api)
Examples:
References
1---2name: "bulkhead-pattern"3description: "Designs bulkhead isolation for services: resource partitioning, thread pool sizing, connection limits, and failure containment. Use when working with capacity planning, pool isolation, failure test, api or when the user mentions capacity planning, pool isolation, failure test, api."4license: "MIT"5compatibility: "Requires docker, java, jcmd, jstack, top, ulimit. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/bulkhead-pattern8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(ab:*) Bash(curl:*) Bash(docker:*) Bash(java:*) Bash(jcmd:*) Bash(jstack:*) Bash(ps:*)"12---1314Designs bulkhead isolation for services: resource partitioning, thread pool sizing, connection limits, and failure containment.1516## Agentic Workflow: Read -> Reason -> Act (bulkhead-pattern)1718You are **Bulkhead Pattern** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `bulkhead-pattern`21- Domain: Designs bulkhead isolation for services: resource partitioning, thread pool sizing, connection limits, and failure containment.22- **capacity-planning**: Measure and size bulkhead partitions. — `ps -o nlwp,pcpu,pmem,rss -p $(pgrep -f my-api)`23- **pool-isolation**: Configure isolated thread pools and connection pools. — `java -XX:+PrintFlagsFinal -version | grep -i threads`24- **failure-test**: Verify a partition failure does not exhaust shared resources. — `ab -n 5000 -c 200 http://localhost:8080/api/slow`25- Check `knowledge` and `prerequisites: docker, java, jcmd, jstack`2627### 2. Reason — think for `bulkhead-pattern`28- For `capacity-planning`: Measure and size bulkhead partitions. — decide which checks to run29- For `pool-isolation`: Configure isolated thread pools and connection pools. — decide which checks to run30- For `failure-test`: Verify a partition failure does not exhaust shared resources. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `bulkhead-pattern` tools34- Tools: `Glob`, `Grep`, `Read`, `Ps`, `Ulimit` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `bulkhead-pattern:79482e43`3738# Bulkhead Pattern3940## What this skill does4142Designs bulkhead isolation so one service partition cannot exhaust shared resources: sizing thread/connection pools, partitioning by dependency or tenant, and verifying failure containment with load tests.4344## When to use4546- One slow dependency is starving the whole service47- Multi-tenant APIs need isolated quotas48- Adding capacity planning for thread pools4950## Real commands5152```bash53# Measure current capacity54ps -o nlwp,pcpu,pmem,rss -p $(pgrep -f my-api)55ss -s56ulimit -n5758# Inspect pool usage (JVM)59jstack $(pgrep -f app.jar) | grep -c '"pool-'60curl -s http://localhost:8080/actuator/metrics/executor.active6162# Failure containment test63ab -n 5000 -c 200 http://localhost:8080/api/slow64curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/api/fast65```6667## Design rules6869- One pool per dependency/tenant group: pool-a, pool-b70- Pool size = max concurrent calls the dependency can serve71- Queue lengths bounded; overflow rejects fast (503)7273## Testing7475- Saturate one partition with ab; assert the other partition stays healthy76- Watch thread counts with top/jstack during the test7778## Best practices7980- Separate pools for CPU vs I/O work81- Set short queue timeouts so rejection is immediate82- Monitor pool utilization and size alerts on saturation8384## Capabilities8586### capacity-planning87Measure and size bulkhead partitions.8889**Parameters:**90- `pid` (string): Process ID or pgrep pattern91- `fd_limit` (number): File descriptor limit9293**Commands:**94- `ps -o nlwp,pcpu,pmem,rss -p $(pgrep -f my-api)`95- `ulimit -n`96- `ss -s`97- `docker stats --no-stream`98- `vmstat 1 5`99100**Examples:**101- ps -o nlwp,pcpu,pmem -p $(pgrep -f my-api)102- ss -s | grep -E 'estab|total'103- docker stats --no-stream $(docker ps -q) | column -t104105### pool-isolation106Configure isolated thread pools and connection pools.107108**Parameters:**109- `pool_name` (string): Thread pool name110- `pool_size` (number): Pool size111112**Commands:**113- `java -XX:+PrintFlagsFinal -version | grep -i threads`114- `jstack $(pgrep -f my-api) | grep -c 'pool-'`115- `jcmd $(pgrep -f my-api) Thread.print | grep -A2 'pool-'`116- `curl -s http://localhost:8080/actuator/metrics/executor.active`117118**Examples:**119- jstack $(pgrep -f app.jar) | grep -c '"pool-'120- curl -s http://localhost:8080/actuator/metrics/executor.active | jq '.measurements'121- jcmd $(pgrep -f app.jar) Thread.print > threads.txt122123### failure-test124Verify a partition failure does not exhaust shared resources.125126**Parameters:**127- `slow_endpoint` (string): Endpoint under failure128- `fast_endpoint` (string): Endpoint that must stay healthy129130**Commands:**131- `ab -n 5000 -c 200 http://localhost:8080/api/slow`132- `curl -s -o /dev/null -w "%{http_code} %{time_total}\n" http://localhost:8080/api/fast`133- `watch -n1 'curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/api/fast'`134- `top -b -n 3 -p $(pgrep -f my-api)`135136**Examples:**137- ab -n 5000 -c 200 http://localhost:8080/api/slow; curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/api/fast138- watch -n1 'curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080/api/fast'139- top -b -n 3 -p $(pgrep -f app.jar) | tail -12140141## References142- [Bulkhead Pattern (Microsoft)](https://learn.microsoft.com/en-us/azure/architecture/patterns/bulkhead)143- [Resilience4j Bulkhead](https://resilience4j.readme.io/docs/bulkhead)144- [Isolation (Istio)](https://istio.io/latest/docs/tasks/traffic-management/circuit-breaking/)