Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GlobalProfileSync πŸš€

Distributed State Synchronization in Java

GlobalProfileSync is a Java-based distributed profile synchronization system built for multi-server environments using Redis Pub/Sub, local caching, asynchronous processing, and failure fallback.

Originally developed for a distributed Minecraft network, the project addresses backend problems that are common across distributed applications: state synchronization, cache invalidation, concurrency, dependency failures, and consistency across independent instances.


⚑ Engineering Highlights

  • Distributed State Sync β€” Redis Pub/Sub propagates profile updates across independent server instances.
  • Fast Local Reads β€” ConcurrentHashMap provides thread-safe in-memory caching without requiring a Redis round trip for every request.
  • Asynchronous Processing β€” CompletableFuture and ExecutorService isolate potentially blocking operations from latency-sensitive application threads.
  • Graceful Degradation β€” Local YAML persistence provides fallback behavior when Redis becomes temporarily unavailable.
  • Dependency Injection β€” Core services use constructor injection instead of static global dependencies, improving testability and separation of concerns.
  • Concurrent Metrics β€” LongAdder tracks cache hit/miss metrics with low contention.
  • Automated Testing β€” JUnit 5 and Mockito validate service logic, synchronization behavior, and failure paths.

πŸ— Architecture

A profile update follows an event-driven synchronization flow:

  1. ProfileService updates the shared profile state.
  2. Redis publishes an update event.
  3. Other application instances receive the event.
  4. Their local caches are invalidated or refreshed.
  5. If Redis is unavailable, the persistence layer falls back to local storage.

This separates shared state synchronization from local read performance.

Key Trade-Off

Redis is treated as an external dependency that can fail.

Instead of allowing a temporary Redis outage to immediately make profile operations unavailable, the system can fall back to local persistence.

The trade-off favors temporary local availability over complete service failure during dependency outages.


🧡 Concurrency & Reliability

The system operates in a concurrent environment where multiple events and profile operations can execute simultaneously.

Key mechanisms include:

  • ConcurrentHashMap for thread-safe local state;
  • CompletableFuture for asynchronous workflows;
  • controlled ExecutorService lifecycle;
  • Jedis connection pooling;
  • Redis Pub/Sub for event propagation;
  • LongAdder for concurrent metrics;
  • explicit resource cleanup during shutdown.

πŸ›  Tech Stack

Area Technology
Language Java 8
Distributed Store Redis
Redis Client Jedis
Messaging Redis Pub/Sub
Caching ConcurrentHashMap
Concurrency CompletableFuture, ExecutorService
Fallback Storage YAML
Testing JUnit 5, Mockito
Build Maven
Runtime OpenJDK / Amazon Corretto

πŸ§ͺ Testing

The architecture allows core behavior to be tested without requiring a live Redis instance.

Tests cover areas such as:

  • profile service behavior;
  • cache hit/miss scenarios;
  • Redis failures;
  • fallback activation;
  • synchronization events;
  • resource lifecycle management.

Run the test suite:

mvn test


πŸ’‘ What This Project Demonstrates

GlobalProfileSync demonstrates practical Java engineering experience with:

Distributed Systems Β· Redis Pub/Sub Β· Event-Driven Architecture Β· Concurrency Β· Cache Invalidation Β· Asynchronous Processing Β· Graceful Degradation Β· Dependency Injection Β· Automated Testing

Although the original runtime is a multi-server game platform, the core engineering challenges are the same ones found in distributed backend systems: shared state, synchronization, concurrency, caching, consistency, and network dependency failures.

About

πŸš€ High-performance, distributed profile synchronization system for Minecraft networks. Engineered with a Service-Oriented Architecture (SOA), Redis Pub/Sub for real-time consistency, and a multi-layered resilience strategy. Built for production-grade scalability.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages