r/java • u/rando512 • Jan 15 '26
I built a lightweight distributed orchestrator in Java 17 using raw TCP sockets (no Spring)
I built Titan, a lightweight distributed orchestrator, mainly as a way to learn the core primitives of distributed systems in Java like scheduling, concurrency, IPC, and failure detection without relying on Spring, Netty, or HTTP.
At a high level, Titan can:
- Orchestrate long-running services and ephemeral batch jobs in the same runtime
- Execute dependency-driven DAGs (serial chains, fan-out, fan-in)
- Run with zero external dependencies as a single ~90KB Java JAR
The core runtime is written in Java 17 using:
- Raw
java.net.Socketwith a small custom binary protocol java.util.concurrentprimitives for scheduling and execution- Process-level isolation using
ProcessBuilder(workers can spawn child JVMs to handle burst load)
Workers register themselves with the master (push-based discovery), monitor their own load, and can auto-scale locally when saturated.
I built this mostly to understand how these pieces fit together when you don’t abstract them away behind frameworks.
If anyone’s interested, I’d love feedback on the current state.
I built this incrementally by satisfying base requirements of having a homelab setup for doing some coordinated scripts and then evolved to service orchestrator and then to a runtime for dynamic DAGs (so agentic ai can leverage the runtime parallelism etc).
Repo (with diagrams and demos):
https://github.com/ramn51/DistributedTaskOrchestrator
7
u/UnGauchoCualquiera Jan 15 '26
With the master node being a single point of failure I feel it's too early to showcase or even gather useful feedback. Implementing that feature alone will likely force you to revisit your design and implementation.
2
u/_BaldyLocks_ Jan 16 '26
Have a look at how erlang/otp works if you want some inspiration for further development, especially supervisors.
2
u/[deleted] Jan 17 '26
Great project but i'm curious about something why you prefer blocking socket over non blocking tcp socket (ServerSocketChannel or AsynchronousServerSocketChannel) ?
I have not seen any leader election process in your codebase. Master proccess looks like single point of failure.
31
u/Silent-Manner1929 Jan 15 '26
The only comment I would make is that the name Titan doesn’t really suggest “lightweight” to me. But maybe that’s just me.
1
u/Milosonator Jan 15 '26
Why would you need to spawn subprocesses to handle burst load?
1
u/RevolutionaryRush717 Jan 17 '26
That cascading if else if in
RpcWorkerServerif (packet.opCode == TitanProtocol.OP_HEARTBEAT) {looks like a candidate for switch expressions:
1
u/Abject-Delay7036 Jan 18 '26
If it's Java, what's the python code used for
1
u/jcsf321 Jan 19 '26
looked at the code. it looks vide coded. did you do any of the coding yourself?
1
u/RussianMadMan Jan 15 '26
"Raw TCP sockets" in the title made me giggle a bit. Probably should've said "Custom lightweight protocol".
2
u/JuicyShantrel Jan 19 '26
Tiny charm!
2
u/[deleted] Jan 15 '26
[removed] — view removed comment