# Optimize Rust Lambda Concurrency

Rust Lambda handlers often mix I/O and CPU work, which can block runtimes or waste parallelism. This skill guides Claude, Codex, and Claude Code toward clear async, blocking, and Rayon patterns.

## Install

```bash
npx skillstore add emillindfors/async-sync-advisor
```

## Metadata

- Status: approved
- Slug: emillindfors-async-sync-advisor
- Version: 1.0.0
- Author version: 1.0.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: 33bba5515cdc75de54ca4d0a0532a308b5f84e5691aef8ff058be885061cda53
- Author: EmilLindfors
- GitHub username: EmilLindfors
- License: MIT
- Repository: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-lambda/skills/async-sync-advisor
- Ref: a06681402992ceae98ba04d54cfd4ab004862696
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 80
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/emillindfors-async-sync-advisor
- Manifest: https://skillstore.pages.dev/api/skills/emillindfors-async-sync-advisor/manifest

## Capabilities

- Identifies whether a Rust Lambda workload is I/O-bound, CPU-bound, or mixed.
- Recommends tokio async patterns for independent network, database, and storage operations.
- Suggests spawn\_blocking when CPU-intensive work would block the async runtime.
- Shows when Rayon can parallelize CPU-bound collection processing.
- Explains common mistakes such as sequential I/O and CPU work inside async handlers.

## Use Cases

- Review a New Lambda Handler: Check whether a new Rust Lambda handler should use async I/O, blocking work, or both.
- Improve Lambda Performance: Find places where sequential awaits or CPU work may reduce throughput.
- Teach Concurrency Tradeoffs: Explain when tokio, spawn\_blocking, and Rayon fit different Lambda workloads.

## Prompt Templates

### Classify My Handler

```
Review this Rust Lambda handler. Tell me whether the workload is I/O-bound, CPU-bound, or mixed, and suggest the best concurrency pattern.
```

### Fix Blocking Work

```
Find CPU-intensive work in this async Rust Lambda handler. Suggest where spawn_blocking should be used and explain the tradeoffs.
```

### Parallelize Processing

```
Review this Lambda handler that processes many items. Decide whether Rayon is appropriate, and describe how to combine it with async I/O safely.
```

### Design a Mixed Pipeline

```
Design a Rust Lambda concurrency plan for downloading records, processing them, and uploading results. Separate async phases from blocking or parallel phases.
```

## Limitations

- Does not run benchmarks, profilers, or load tests.
- Focuses on Rust AWS Lambda handlers, not every Rust concurrency use case.
- Does not provide complete production error handling or infrastructure configuration.
- Assumes tokio, futures, and Rayon are acceptable dependencies for the project.

## Best Practices

- Classify each handler phase as I/O-bound, CPU-bound, or mixed before choosing a pattern.
- Use async joins for independent I/O operations that can safely run concurrently.
- Move CPU-heavy work away from the async runtime with spawn\_blocking or a parallel worker pattern.

## Anti Patterns

- Do not make CPU-heavy work async only because it runs inside an async handler.
- Do not await independent I/O calls sequentially when their order is not required.
- Do not add Rayon to small workloads without checking overhead and Lambda CPU limits.

## Security Audit

- Audited at: 2026-07-06T14:31:26.67\+00:00
- Summary: All static external command findings are false positives caused by Markdown inline code and fenced Rust examples. I found no prompt injection, data exfiltration intent, or instructions to execute external commands.

## Stats

- Views: 109
- Downloads: 10
- Favorites: 0
- Popularity score: 0
