Notícias
Notícias
5 min de leitura
21 de outubro de 2026

Seu agent usa polling (WebSocket é 10x mais rápido)

WebSocket GA: 300M connections proven. Seu agent? HTTP polling (lento, caro). Real-time agents = WebSocket NOW (90% cost down).

Equipe OpenClaw

Equipe OpenClaw · Time de Engenharia & Produto

A Equipe OpenClaw é formada por engenheiros, designers e especialistas em IA dedicados a construir a melhor plataforma de agentes conversacionais para negócios brasileiros. Combinamos expertise…


Seu agent usa polling (WebSocket é 10x mais rápido)

What just happened (October 2026):

Vercel released:

"WebSocket support generally available (GA, production-ready)."

"Proof: 300 million connections served, 15 million daily."

"Impact: Sub-100ms latency, 90% cost reduction for real-time apps."

What this means for your company:

Current situation (HTTP polling): Your agent: Runs on HTTP (request-response) How it works: 1. Customer asks: "What's my order status?" 2. Browser sends request (HTTP POST) 3. Network latency: 50-100ms (to reach your server) 4. Server processes: 100-200ms (LLM inference) 5. Response sent: 50-100ms (back to customer) 6. Customer sees answer: 200-400ms (total)

But: Browser polls every 2-5 seconds ("Any update?")
7. Polling request sent: 50-100ms
8. Server responds: 50ms ("No update")
9. Repeat every 2-5s: 12-30 requests per minute

Latency: 200-400ms per interaction (feels slow)
Cost: 12-30 HTTP requests per user per minute

Scale to 1000 concurrent users:
  12,000-30,000 requests per minute
  = 200-500 requests per second
  = $5000-20,000/month just in compute costs
  

Problem: Polling is expensive at scale Why? - Every 2s: Poll (even if no data) - 50% of polls: No data (wasted request) - Network latency: Adds overhead - Server processing: Even for "no change" - Cost multiplies: 1000 users = 30k requests/min

Customer experience: "Why is my agent so slow?" "Why does it feel like lag?" "I'll use competitor (has real-time)" Result: Customer churn

After (WebSocket): Your agent: Runs on WebSocket (bidirectional stream) How it works: 1. Customer says: "What's my order status?" 2. WebSocket sends: Data instantly (no HTTP overhead) 3. Network latency: <50ms (persistent connection) 4. Server processes: 100-200ms (LLM inference) 5. Response sent: <10ms (already connected) 6. Customer sees: <250ms total (feels instant)

Polling: None (WebSocket pushes data)
7. Server has update: Pushes to client (no request needed)
8. Client receives: <50ms (already listening)

Latency: <250ms per interaction (feels real-time)
Cost: 0 polling overhead

Scale to 1000 concurrent users:
  1 connection per user (persistent)
  = 1000 connections (not 30k requests/min)
  = $500-2000/month (90% cheaper)
  

Benefit: WebSocket is designed for real-time Why? - Persistent connection (no setup overhead) - Bidirectional (push data, not pull) - Low latency (<50ms roundtrip) - Efficient (only send when data changes) - Cheap at scale (connections, not requests)

Customer experience: "Wow, this is instant!" "Feels like talking to a real person" "Switching from competitor because this is so smooth" Result: Customer delight + retention


Why WebSocket matters now

The HTTP polling problem (technical)

How polling works (and why it sucks):

HTTP polling architecture: Client (browser) → Server (agent)

Timeline: t=0s: Client sends: "Any updates?" (HTTP request) t=0.05s: Network latency (request reaches server) t=0.15s: Server checks database ("No updates") t=0.2s: Server sends response (200 OK, no data) t=0.25s: Network latency (response reaches client) t=0.25s: Client waits 2 seconds t=2.25s: Client sends: "Any updates?" (again) t=2.3s: Network latency t=2.4s: Server checks ("No updates") t=2.45s: Response sent t=2.5s: Client receives (still no data) t=2.5s: Client waits 2 more seconds t=4.5s: Client sends: "Any updates?" (third request) ... t=4.55s: Server finally has update (agent finished reasoning) t=4.6s: Server sends response (with answer) t=4.65s: Client receives (sees answer)

Total latency: 4.65 seconds (from update to display)
Wasted requests: 2 (third request got the data)
Wasted processing: 2 server checks for nothing
Cost: 3 HTTP requests for 1 update

Problems with HTTP polling:

  1. Latency: 2-5 second delay (depends on poll interval)
  2. Overhead: 50% of requests return no data (wasted)
  3. Cost: 3 requests instead of 1
  4. Network: Constant reconnection overhead
  5. Server load: 3x load compared to push model

At scale (1000 users): Poll interval: 2 seconds Requests per user per minute: 30 Total requests per minute: 30,000 Total requests per second: 500

Cost (Vercel Functions): 500 requests/s * 86,400 seconds/day = 43.2M requests/day At $0.0001 per request = $4,320/day = $130k/month

With WebSocket: 1000 connections = 1000 persistent connections Cost per connection: ~$0.001/second (variable) = $0.001 * 1000 * 86,400 = $86/day = $2,600/month

Savings: $130k - $2.6k = $127k/month (98% reduction)

Why WebSocket is the answer

WebSocket architecture (the right way):

WebSocket connection: Client (browser) → Server (agent)

Setup (one-time): t=0s: Client initiates: "Open WebSocket" t=0.05s: Network latency t=0.1s: Server accepts (connection established) t=0.15s: Network latency t=0.15s: Connection ready (persistent) Cost: 1 setup (amortized over 30+ minutes)

Update flow: t=0s: Agent finishes reasoning (answer ready) t=0s: Server sends: {type: "answer", data: "Order shipped"} t=0.05s: Network latency t=0.05s: Client receives (displays answer)

Total latency: 0.05 seconds (5x faster than polling)
Overhead: 0 (no polling, no wasted requests)
Cost: 1 message (not 3 requests)

Benefits of WebSocket:

  1. Latency: <100ms (persistent connection)
  2. Efficiency: 0 wasted requests (push only when needed)
  3. Cost: 1 message instead of 3 requests
  4. Network: Single connection (no reconnect overhead)
  5. Server load: 1 message instead of 3 requests

At scale (1000 users): Connections: 1000 (persistent) Messages per user per minute: 2-5 (only when data changes) Total messages per minute: 2000-5000 Total messages per second: 33-83

Cost (Vercel Functions): Active CPU seconds: ~0.1s per message (LLM processing) = 83 messages * 0.1s = 8.3 CPU seconds/second = 8.3 * 86,400 = 717,120 CPU seconds/day At $0.50 per 100k CPU seconds = $3.58/day = $107/month

Comparison: HTTP polling: $130,000/month WebSocket: $107/month Savings: 99.9% cost reduction


Real-world impact (why this matters for your business)

Scenario 1: Customer support agent (WhatsApp)

Before WebSocket:

Setup: Support chatbot using HTTP polling Customer: Asks question via WhatsApp

Timeline: t=0s: Customer asks: "Where's my order?" t=0.2s: WhatsApp sends to your server (HTTP POST) t=0.3s: Your server calls LLM (starts processing) t=2.3s: LLM returns answer (2 seconds to reason) t=2.3s: Your server updates database t=2.3s: Server is ready to send response

But: WhatsApp client polls every 2 seconds t=2.3s: WhatsApp polls ("Any updates?") → Gets response t=2.5s: WhatsApp displays message t=2.5s: Customer sees answer (total 2.5 second delay)

Customer experience: [customer waits 2.5 seconds] Agent: "Your order shipped yesterday" [customer feels slight lag]

Scale (10k concurrent users): Polling: 10k users * 30 polls/min = 300k requests/min Cost: Massive infrastructure needed

After WebSocket: Customer: Asks question via WhatsApp

Timeline: t=0s: Customer asks: "Where's my order?" t=0.1s: WebSocket sends to server (instant, persistent connection) t=0.1s: Your server calls LLM (starts processing) t=2.1s: LLM returns answer (2 seconds to reason) t=2.1s: Server sends answer via WebSocket (instant) t=2.2s: WhatsApp receives (no polling, direct push) t=2.2s: WhatsApp displays message t=2.2s: Customer sees answer (total 2.2 second delay)

Improvement: 0.3 seconds faster (feels instant to user)

Customer experience: [almost no delay] Agent: "Your order shipped yesterday" [feels like real-time conversation]

Scale (10k concurrent users): WebSocket: 10k persistent connections Cost: 90% lower (no polling overhead) Infrastructure: Simpler (connections, not requests)

Scenario 2: Sales agent (live chat)

Before WebSocket:

Setup: Sales chatbot with HTTP polling Prospect: Chats on website

Experience: Prospect: "Tell me about your pricing" [1-2 second delay] Agent: "We have 3 plans: Starter $50/mo..." [1-2 second delay] Prospect: "What's included in Starter?" [1-2 second delay] Agent: "Starter includes: ..." [1-2 second delay]

Prospect feeling: "This is slow. Let me check competitor." Result: Lost deal (perception of poor quality)

Infrastructure cost: 100 concurrent chats 100 * 30 polls/min = 3000 requests/min = 50 requests/second Cost: ~$5000/month

After WebSocket: Prospect: "Tell me about your pricing" Agent: "We have 3 plans: Starter $50/mo..." [instant] Prospect: "What's included in Starter?" Agent: "Starter includes: ..." [instant] Prospect: "How many users?" [instant] Agent: "Unlimited users in all plans" [instant]

Prospect feeling: "Wow, this agent is responsive! I'll buy." Result: Closed deal (perception of quality + real-time)

Infrastructure cost: 100 concurrent connections 100 WebSocket connections (not 3000 requests) Cost: ~$500/month (90% reduction) Savings: $4500/month


How to implement WebSocket for your agent

Option 1: Vercel (easiest)

Why Vercel?

Vercel WebSocket support:

  • Production-proven (300M connections, 15M/day)
  • Easy integration (one configuration change)
  • Auto-scaling (handles traffic spikes)
  • Pricing: Same as HTTP (per CPU second, no connection fee)

Setup (30 minutes):

  1. Create WebSocket handler in Vercel Functions
  2. Upgrade HTTP route to WebSocket
  3. Handle messages in your agent code
  4. Deploy

Example code: javascript export default function handler(req, res) { if (req.headers.upgrade !== 'websocket') { return res.status(400).send('Not WebSocket'); }

const { socket, head } = req.socket._httpMessage.upgradeReq;
socket.on('message', (data) => {
  const message = JSON.parse(data);
  // Call your LLM agent
  const response = await agent.process(message);
  socket.send(JSON.stringify(response));
});

}

Cost: Same as HTTP polling (billed per CPU second)

  • 100 connections: ~$100/month
  • 1000 connections: ~$500/month
  • 10000 connections: ~$2000/month

Comparison (HTTP polling equivalent):

  • 100 connections: ~$10k/month
  • 1000 connections: ~$100k/month
  • 10000 connections: ~$1M/month

Savings: 99% cost reduction

Option 2: AWS API Gateway (enterprise)

Why AWS?

AWS WebSocket support:

  • Enterprise-grade (AWS backing)
  • Serverless (auto-scaling)
  • Integration with Lambda (agent code)
  • Pricing: Per connection-minute + data transfer

Setup (2-3 hours):

  1. Create API Gateway WebSocket API
  2. Create Lambda functions ($connect, $default, $disconnect)
  3. Store connection IDs in DynamoDB
  4. Send messages to all connections (broadcast)
  5. Deploy

Example cost: 100 connections * 30 min avg = 3000 connection-minutes At $0.25 per million connection-minutes = $0.0007/day Data transfer: 1GB/day at $0.09/GB = $0.09/day Total: ~$0.10/day = $3/month

Comparison (HTTP polling equivalent): ~$300/month Savings: 99% cost reduction

Option 3: Custom WebSocket (control)

Why custom?

Custom WebSocket server:

  • Full control (no vendor lock-in)
  • Optimization potential (tune for your use case)
  • Integration with any backend

Setup (1-2 weeks):

  1. Use library: socket.io or ws (Node.js)
  2. Create connection management
  3. Integrate with your agent
  4. Deploy to your infrastructure

Example (Node.js + ws): javascript const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', (ws) => { ws.on('message', async (message) => { const response = await agent.process(message); ws.send(JSON.stringify(response)); }); });

Infrastructure cost: Depends on your setup Self-hosted: ~$50-500/month (depending on load) Container (Docker): ~$20-200/month Kubernetes: ~$100-1000/month

Comparison (HTTP polling on same infrastructure): 2-5x cost Savings: 50-80% with WebSocket


Migration checklist (HTTP polling to WebSocket)

Step-by-step:

□ Week 1: Understand WebSocket □ Read Vercel WebSocket docs (1 hour) □ Review sample code (1 hour) □ Understand connection lifecycle (2 hours)

□ Week 2: Proof of concept □ Create simple echo server (2 hours) □ Test with sample client (2 hours) □ Measure latency improvement (2 hours) □ Calculate cost savings (2 hours)

□ Week 3: Integrate with agent □ Modify agent to work with WebSocket (4 hours) □ Handle connection management (4 hours) □ Test with real messages (4 hours)

□ Week 4: Deploy to staging □ Set up staging environment (2 hours) □ Load test (2 hours) □ Performance validation (2 hours) □ Security review (2 hours)

□ Week 5: Production rollout □ Migrate 10% of users (day 1) □ Monitor metrics (days 1-3) □ Migrate 50% of users (day 4) □ Monitor metrics (days 4-6) □ Full rollout (day 7) □ Celebrate 99% cost reduction 🎉

Total effort: 2-4 weeks (depending on complexity) ROI: Immediate (99% cost reduction)


Vercel's proof (why we know WebSocket is ready)

Production stats:

Vercel WebSocket milestone:

  • Public beta: June 2026
  • Connections served: 300 million (to date)
  • Current rate: 15 million per day
  • GA status: Production-ready

What this means: 300M connections = proof of stability 15M/day = active use by real companies GA release = Vercel betting on this feature

If Vercel is wrong: They lose credibility Reality: They're confident (went GA)

Companies already using (inferred from 15M/day): - Real-time collaboration apps - AI chat applications - Streaming services - Multiplayer games - Live notifications

Verdict: WebSocket is production-proven


Conclusion: WebSocket is the new standard for real-time agents

Summary:

What changed: Vercel released WebSocket GA (production-ready) Proof: 300M connections, 15M daily Implication: HTTP polling is now obsolete

Why it matters: Agents require real-time (sub-100ms latency) HTTP polling: Too slow (1-5s latency) WebSocket: Fast enough (<250ms latency) Cost: 99% reduction (polling is expensive)

What to do: Week 1: Proof of concept (Vercel WebSocket) Week 2: Measure latency + cost savings Week 3: Integrate with your agent Week 4: Deploy to staging Week 5: Production rollout

Timeline: 1 month to WebSocket-powered agents Cost: $0 (if using Vercel, included in compute) Benefit: 99% cost reduction + better UX ROI: 100x (save $100k+/month, improve customers)

Bottom line: HTTP polling for agents = dead technology WebSocket = new standard (production-proven) Your competitors: Probably starting migration now You: Should start this week

Question: Is your agent using WebSocket yet?

→ OpenClaw: WebSocket real-time agents, sub-100ms latency, 99% cost reduction, Vercel WebSocket integration, production-ready real-time agent architecture

Seu agent usa polling = 2-5s latency + caro. WebSocket = 100ms latency + 99% mais barato. Real-time agents = novo normal. ⚡🚀📊


Publicado em 21 de outubro de 2026

Leia também