惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
博客园 - Franky
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
S
SegmentFault 最新的问题
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
有赞技术团队
有赞技术团队
B
Blog RSS Feed
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - 司徒正美
The Cloudflare Blog
博客园_首页
博客园 - 聂微东
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Microservices vs Monolith: When to Split Your Architecture
Ugur Aslim · 2026-06-19 · via DEV Community

Ugur Aslim

Microservices vs Monolith: When to Split Your Architecture

I've rebuilt CitizenApp's backend twice. Once I split it into microservices because "that's what production systems do." I was wrong. We spent 6 months debugging distributed tracing logs instead of shipping features. Then we merged back into a monolith, and velocity tripled.

This post isn't romantic. It's a decision framework for when distributed systems actually pay off—and when they're just complexity theater.

The Monolith Default

Start monolithic. Every successful SaaS I know—Stripe, GitHub, Figma—began as a single codebase. This isn't laziness; it's pragmatism.

A monolith with Astro + FastAPI gives you:

  • Single deployment pipeline. One GitHub Actions workflow deploys everything.
  • Shared database transactions. ACID guarantees without eventual consistency nightmares.
  • Simpler debugging. Stack traces tell the whole story.
  • Lower operational overhead. One container, one set of logs, one database.

For CitizenApp's first 18 months, we ran everything in a single FastAPI app on Render. 50K users. 9 AI features. One database. We shipped features faster than teams with "proper" microservices architecture.

Cost matters too. A monolith on Render costs ~$50/month to start. Your first microservice architecture? You're looking at orchestration, service mesh tooling, monitoring agents, minimum 3-4x the infrastructure cost.

When Splitting Actually Wins

Stop generalizing about "scale." Microservices solve specific problems:

1. Independent Deployment Cycles

Your ML pipeline team needs to redeploy inference workers 20x daily. Your API team ships weekly. A monolith couples them.

Split when: Different services have different deployment frequencies or risk profiles.

# BAD: Monolith—one team blocks another
class FastAPIApp:
    def get_user(self, user_id: str):
        return db.query(User).filter(User.id == user_id).first()

    def generate_embedding(self, text: str):
        # If this crashes, entire API goes down
        return claude_client.create_embedding(text)

# GOOD: Separate services
# api/main.py
@app.get("/users/{user_id}")
async def get_user(user_id: str):
    return {"id": user_id, "name": "John"}

# ml/embedding_service.py
@app.post("/embed")
async def embed_text(text: str):
    # Independent scaling, independent deploys
    return await claude_client.create_embedding(text)

2. Resource Isolation

One feature consumes all database connections and starves the rest. A monolith makes this a crisis.

Split when: You need to isolate resource usage for reliability.

I watched CitizenApp's document processing eat 40 DB connections while user login requests queued. We extracted it:

# Dedicated PostgreSQL pool for background jobs
background_pool = create_engine(
    DATABASE_URL,
    pool_size=5,
    max_overflow=10,
    pool_pre_ping=True  # Verify connections are alive
)

# Main API keeps its own pool
api_pool = create_engine(
    DATABASE_URL,
    pool_size=20,
    max_overflow=20
)

This was a config fix, not a service split. Know the difference.

3. Technology Lock-in

Your team knows Python. A new requirement needs Node.js + WebSockets. You hire specialists who want to own their stack.

Split when: Technology genuinely constrains your team, not ego.

At CitizenApp, our real-time collaboration engine became a separate Node.js service. Python developers built the core product. Node developers owned the socket layer. Clear boundaries. Clear ownership.

4. Scale-Specific Optimization

You're serving 100K concurrent WebSocket connections for real-time features. Your API serves REST requests with average 200ms response time.

These have opposite optimization strategies. A shared codebase gets tangled.

Split when: Different services optimize for different performance profiles.

The Checklist: Stay Monolithic Unless...

□ Different services deploy 5+ times per day independently?
□ Resource contention causes production incidents monthly?
□ You need different tech stacks that teams prefer to own?
□ One service requires horizontal scaling others don't?
□ Your database is a bottleneck (not your app logic)?
□ You have 50+ engineers who can't maintain coherent monolith?

If you checked fewer than 3 boxes: stay monolithic.

Cost Reality

Monolith (Render, 10K users): $50/month

Basic microservices (Kubernetes, observability): $2K+/month

Production microservices (service mesh, distributed tracing, on-call rotations): $10K+/month

The last line item is often invisible. Microservices require:

  • On-call rotations across services
  • Distributed tracing (DataDog, New Relic)
  • API gateway and load balancing
  • Service mesh (Istio/Linkerd) at scale
  • Chaos engineering to test failure scenarios

Gotcha: The False Signal

Most teams split too early because of vanity architecture.

I've seen startups choose Kubernetes on day 1. "We want to scale." They're running 3 Docker containers. Kubernetes doesn't make you Netflix; shipping features does.

What actually burned me: splitting CitizenApp's authentication into a separate service "for security." We added:

  • JWT validation in two places (inconsistency bugs)
  • Network calls to the auth service on every request
  • Debugging distributed auth flows took 3x longer
  • We eventually merged it back

The real cost of microservices is cognitive load. Every service boundary is a place to debug, secure, test, and monitor. You're paying that cost immediately.

The Right Approach

  1. Start monolithic. Ship features. Measure what actually breaks.
  2. Only split services that are provably constrained. Database? Compute? Deployment frequency?
  3. Use clear contracts. If you split, define OpenAPI schemas, versioning strategy, and timeout policies upfront.
  4. Monitor the boundary costs. If inter-service calls become a bottleneck, you split too aggressively.

For CitizenApp, we stayed monolithic for 18 months, split the ML pipeline (legitimate reason), and kept everything else together. The result: we shipped 9 AI features faster than competitors with "proper" distributed systems.

Architectural purity is cheaper than shipped features.