원클릭으로
scalability
Design scalable systems with horizontal scaling, load balancing, caching, message queues, and stateless service architecture.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Design scalable systems with horizontal scaling, load balancing, caching, message queues, and stateless service architecture.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | scalability |
| description | Design scalable systems with horizontal scaling, load balancing, caching, message queues, and stateless service architecture. |
Purpose: Design systems that handle growth in users, data, and traffic.
Approaches: Horizontal scaling, load balancing, caching, async processing, stateless services.
| Approach | Description | When to Use |
|---|---|---|
| Vertical | Bigger server (more CPU/RAM) | Quick fix, limited by hardware |
| Horizontal | More servers | Long-term, unlimited growth |
Prefer horizontal scaling - Add more instances rather than bigger servers.
// ❌ Stateful (doesn't scale)
public class OrderController : ControllerBase
{
private static Dictionary<int, Order> _orders = new(); // Shared state!
[HttpPost]
public IActionResult CreateOrder(Order order)
{
_orders[order.Id] = order; // Lost on restart or different instance
return Ok();
}
}
// ✅ Stateless (scales horizontally)
public class OrderController : ControllerBase
{
private readonly IOrderRepository _repository;
[HttpPost]
public async Task<IActionResult> CreateOrder(Order order)
{
await _repository.SaveAsync(order); // Persisted to database
return Ok();
}
}
# NGINX load balancer config
upstream api_servers {
least_conn; # Route to server with fewest connections
server api1:5000;
server api2:5000;
server api3:5000;
}
server {
listen 80;
location / {
proxy_pass http://api_servers;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Strategies:
// Cache frequently accessed data
public class ProductService
{
private readonly IDistributedCache _cache;
private readonly IProductRepository _repo;
public async Task<Product> GetProductAsync(int id)
{
var cacheKey = $"product:{id}";
var cached = await _cache.GetStringAsync(cacheKey);
if (cached != null)
return JsonSerializer.Deserialize<Product>(cached);
var product = await _repo.GetByIdAsync(id);
await _cache.SetStringAsync(cacheKey,
JsonSerializer.Serialize(product),
new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
});
return product;
}
}
using RabbitMQ.Client;
// Producer - Queue heavy operations
public class OrderService
{
private readonly IConnection _connection;
public async Task<Order> CreateOrderAsync(OrderDto orderDto)
{
var order = await _repository.CreateAsync(orderDto);
// Queue email and inventory update (don't block)
await _queue.PublishAsync("order.created", new
{
OrderId = order.Id,
CustomerEmail = order.CustomerEmail
});
return order;
}
}
// Consumer - Process in background
public class OrderProcessor : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await _queue.SubscribeAsync("order.created", async message =>
{
await _emailService.SendOrderConfirmationAsync(message.OrderId);
await _inventoryService.UpdateStockAsync(message.OrderId);
});
}
}
// Write to primary
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("Primary")));
// Read from replicas
builder.Services.AddDbContext<ReadDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("ReadReplica")));
public class UserService
{
private readonly AppDbContext _writeDb;
private readonly ReadDbContext _readDb;
public async Task<User> GetUserAsync(int id) =>
await _readDb.Users.FindAsync(id); // Read from replica
public async Task CreateUserAsync(User user)
{
_writeDb.Users.Add(user);
await _writeDb.SaveChangesAsync(); // Write to primary
}
}
// Shard by user ID
public class ShardedUserRepository
{
private readonly List<AppDbContext> _shards;
private AppDbContext GetShard(int userId)
{
var shardIndex = userId % _shards.Count;
return _shards[shardIndex];
}
public async Task<User> GetUserAsync(int userId)
{
var shard = GetShard(userId);
return await shard.Users.FindAsync(userId);
}
}
// Use CDN for images, CSS, JS
<img src="https://cdn.myapp.com/images/logo.png" />
<link href="https://cdn.myapp.com/css/styles.css" rel="stylesheet" />
// Configure CDN
builder.Services.Configure<StaticFileOptions>(options =>
{
options.OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers.Add("Cache-Control", "public,max-age=31536000");
};
});
using AspNetCoreRateLimit;
builder.Services.Configure<IpRateLimitOptions>(options =>
{
options.GeneralRules = new List<RateLimitRule>
{
new RateLimitRule
{
Endpoint = "*",
Period = "1m",
Limit = 100
}
};
});
app.UseIpRateLimiting();
# Kubernetes HPA (Horizontal Pod Autoscaler)
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: api-autoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: api
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
See Also: 05-performance.md • 06-database.md • 15-logging-monitoring.md
Last Updated: January 13, 2026
Build production-ready AI agents with Microsoft Foundry and Agent Framework. Covers agent architecture, model selection, orchestration, tracing, and evaluation.
Design robust REST APIs with proper versioning, pagination, error handling, rate limiting, and OpenAPI documentation.
Structure projects for maintainability and scalability with clean architecture, separation of concerns, and consistent project layouts.
Systematic code review and audit practices including automated checks, security audits, compliance verification, and review checklists.
Manage application configuration with environment variables, Azure Key Vault, feature flags, and environment-specific settings.
Fundamental coding principles for production development including SOLID, DRY, KISS, and common design patterns with C# examples.