Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security DownloadsGitHub Release: ollama/ollama v0.34.4-rc0 (23.09.2026)(23.09.2026 um 02:53 Uhr)
Sichere ProgrammierungMy fact-checker said CONFIRMED about a group that doesn't exist(23.09.2026 um 02:13 Uhr)
Sichere ProgrammierungZero-Friction Payment Architectures for Global Scalability(23.09.2026 um 02:20 Uhr)
IT Security DownloadsGitHub Release: ollama/ollama v0.34.4-rc0 (23.09.2026)(23.09.2026 um 02:53 Uhr)
Sichere ProgrammierungMy fact-checker said CONFIRMED about a group that doesn't exist(23.09.2026 um 02:13 Uhr)
Sichere ProgrammierungZero-Friction Payment Architectures for Global Scalability(23.09.2026 um 02:20 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Synchronization Across Distributed Servers: DB vs Redis vs Actor

In distributed systems, one of the most common and tricky challenges is ensuring synchronized access to shared resources across multiple server instances. For example, when a user initiates a money transfer, updates a shared task list, or…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In distributed systems, one of the most common and tricky challenges is ensuring synchronized access to shared resources across multiple server instances.



For example, when a user initiates a money transfer, updates a shared task list, or interacts with a counter, the request may hit any instance in your cluster. Unless synchronized properly, this can result in race conditions, inconsistent state, or data corruption.









Traditional Synchronization Techniques



Developers typically reach for one of two well-known approaches:






1. Database Locking



Using pessimistic locking (SELECT ... FOR UPDATE) or JPA's @Lock(PESSIMISTIC_WRITE):




  • Simple and widely supported

  • Ties up database connections

  • Increases contention and slows down unrelated queries






2. Redis Locks



Using a distributed lock pattern (e.g., Redlock via Redisson):




  • Offloads lock state from the DB

  • Requires Redis infrastructure

  • Needs careful retry/backoff handling to be safe and reliable



Both methods require additional complexity and infrastructure to maintain, especially at scale.









A Simpler Alternative: Clustered Sharded Actors



Thanks to spring-boot-starter-actor, there's a third option: actor-based synchronization with no external system required.



The library integrates Apache Pekko cluster sharding into Spring Boot, enabling you to model shared entities as singleton actors across your cluster.



If two concurrent requests targeting the same logical ID (like user-123) arrive at different servers, the actor system ensures that:




  • Only one instance of the actor is created for that ID

  • All messages for that ID are routed to and handled by that actor, sequentially



This eliminates the need for locks or external coordination.









Real-World Comparison: DB vs Redis vs Actor



We compared three implementations of a synchronized counter increment:





  • db: Uses pessimistic DB locking


  • redis: Uses Redis-based distributed lock


  • actor: Uses spring-boot-starter-actor’s sharded actor system






Test Setup




  • 3 Spring Boot instances (ports 8080, 8081, 8082)

  • Each instance received 3,000 concurrent POST requests (total: 9,000)

  • Each method was benchmarked independently using Apache Bench (ab)

  • Final value was retrieved via: GET /counter/{method}/{counterId}









Results Summary
































Method Counter Final Value External Infra Notes
DB Lock 9,000 MySQL High DB load;
Redis 9,000 Redis Required retry logic; slower throughput under load
Actor 9,000 None High throughput, simple implementation


Although many requests technically "failed" at the HTTP layer (due to thin responses or benchmarking artifacts), the counter logic worked perfectly in all cases.









Why the Actor Model Is Effective



Using actors for synchronization offers several advantages:





  • Correctness: Each logical ID maps to a single actor that serializes access


  • Simplicity: No retry logic or lock expiration handling


  • Infrastructure-free: No Redis or lock coordination service needed


  • Scalability: Naturally distributed across nodes without contention



This model fits naturally into workloads where each entity (e.g., user, session, document) can be isolated and updated independently.









How to Get Started



Refer to the examples.









Summary


















































Feature DB Lock Redis Lock Actor
External Infra Required Yes Yes No
Lock Coordination Overhead High Medium Low
Error-Prone Retry Logic No Yes No
Throughput Under Load Degrades Moderate Stable
Code Complexity Low Medium Low
Horizontal Scalability Limited Good Excellent


If you're building a distributed Spring Boot system and need reliable, low-latency synchronization without operational burden, consider giving the actor model a try.









Source Code



You can find the complete working example, including the benchmarking script, on GitHub:


🔗 spring-boot-starter-actor — Synchronization Example

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Synchronization Across Distributed Servers: DB vs Redis vs Actor

Thematisch verwandte Begriffe: Synchronization, Across, Distributed, Servers · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-17636 | IBM Financial Transaction Manager (FTM) for RedHat OpenShift could allow…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick