- Java 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
On macOS a client that connects and resets at once ended the whole service, without a token: an option cannot be set on a socket that was reset, the constructor of FromClientConnection threw, and that ended the accept loop, join() and the process. Each would also have kept a place of maxConnections. A failure to accept (no file descriptor left) ended it too, and a server socket that macOS took away did not: the accept stayed parked and the service deaf. HttpServer and MqttBroker now share AcceptLoop: whatever one connection throws closes that one, a failure to accept is waited out, at most 128 in a row, and a socket that is gone ends the loop within five seconds, so that the service is started again. A connection counts once its close counts it back. TASKS.md: what clients leave unread fills the kernel's network memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| docs | ||
| src | ||
| .claudeignore | ||
| .gitignore | ||
| CLAUDE.md | ||
| lombok.config | ||
| pom.xml | ||
| README.md | ||
| TASKS.md | ||
Silver
There is no such thing as a silver bullet
Every cloud has a silver lining
A small Java library for writing microservices: HTTP server and client, dependency injection, YAML, object mapping, logging, and the utilities that go with them.
No runtime dependencies. Not Spring, not Jetty, not Jackson, not SLF4J — nothing on the classpath but the JDK and this jar. A service built on it is a single jar that starts in milliseconds.
Requires JDK 25.
Why
Spring Boot is excellent and enormous. For a handful of small services on one machine, most of that is weight without benefit: slow starts, large jars, a dependency tree that has to be watched for CVEs, and a lot of behaviour that is configured rather than written. Silver is the opposite trade — small enough to read end to end, with the behaviour in the code where it can be followed.
The name is the joke: there is no silver bullet. This is not a better Spring, it is a smaller one that fits a particular situation.
What is in it
| Package | What |
|---|---|
httpio.server |
HTTP/1.1 server, annotation-routed endpoints, WebSockets |
httpio.client |
HTTP/1.1 client, connection pooling, WebSockets |
httpio.common |
Shared HTTP types: headers, cookies, content types, status |
yaml |
YAML reader, JSON writer |
objectmapper |
Map ↔ object mapping: builders, constructors, records, fields |
util |
DIManager, collection wrappers, caches, thread helpers |
log |
Small logger, SLF4J-compatible if SLF4J happens to be present |
auth |
Ed25519 token minting and verification |
io.modbus |
Modbus TCP client |
io.mqtt |
MQTT client and broker |
io.smtp |
SMTP client |
conversions |
Type conversion used across the above |
A server
public class Example {
@HttpGet("/hello/{name}")
public String hello(String name) {
return "Hello, " + name;
}
static void main(String... args) {
new HttpServer(HttpServer.HttpServerConfig.builder()
.props(HttpServerProperties.builder().port(8080).build())
.endpointInstance(new Example())
.build())
.start()
.join();
}
}
Path and query variables bind by parameter name, which is why the build needs
javac's -parameters. Return an object and it is serialised; take an object
annotated @FromBody and the request body is deserialised into it.
YAML
final Config config = new Yaml().mapYamlToClass(path, Config.class);
final String json = Yaml.toJsonString(config, 2);
Mapping strategies are tried in order — @CustomMapper, record, Lombok
builder, @AllArgsConstructor, getters and setters, public fields — so most
classes map without being told how.
Maturity
Used in production, for small values of production: it runs PathBox and backs Auth and CasaFlux. Around 30,000 lines with about 1,700 tests against them.
The jar is ~810 KB — 462 classes and nothing else in it, since there are no dependencies to bundle. That is the whole of what a service adds to the JDK to get an HTTP server and client, WebSockets, YAML, object mapping, dependency injection, logging, auth tokens, MQTT, Modbus and SMTP.
The API is not frozen. It is 0.9-SNAPSHOT and things still move when a
consumer turns up a better shape — which is the reason for the version number
rather than an apology for it. What is there is tested and in use; what is
missing is mostly the things three services have not needed yet.
HTTP/1.1 only. No HTTP/2, no HTTP/3.
Benchmarks
Measured against the libraries Silver replaces, with the same inputs for each, on one
machine (Apple M1 Pro, JDK 25, Silver ee2a154, October 2026). A ratio is Silver's
figure against the alternative's.
| Area | Compared with | Silver |
|---|---|---|
| HTTP server | Jetty 12, Spring Boot 4 (MVC, WebFlux) | Level with Jetty, up to 1.5x Spring MVC, the lowest p99 latency. In a 32 MB heap 1.25-5x Spring MVC and 1.2-2.4x WebFlux, and one of only two servers that survive every load phase |
| Footprint | the same | The whole service in a 0.9 MB jar, no dependencies. Starts in 0.18 s (Jetty 0.32 s, Spring 1.2-1.5 s), serves in a 6 MB heap (Jetty 12 MB, Spring MVC 24 MB) |
| JSON | Jackson 2 and 3, Gson | Reads UTF-8 bytes at 0.8-0.9x Jackson while allocating less; maps 2.2x Jackson 3; writes level with Jackson |
| YAML | SnakeYAML, Jackson YAML | 4-4.5x SnakeYAML, 2.4-2.7x Jackson YAML, allocating 2.7-5.9x less |
| HTTP client | JDK, Jetty, Apache, OkHttp | The pooled client is the fastest of the six (1.03-2.4x) |
| MQTT | Moquette, Paho | Broker starts in 76-84 ms (Moquette 188-194 ms) with 57% of its heap; QoS 0 publishing about 10x |
| Modbus | j2mod, digitalpetri | As fast as j2mod, 1.4-1.5x digitalpetri, allocating 50-145x less than j2mod |
| Auth tokens | JJWT | Same Ed25519 cost on a token's first check; repeat checks take 50 ns |
| Logging | Logback, Log4j 2 | 0.76x Logback, with 2.7x its allocation |
Behind: logging; the per-call HTTP client (a socket per request, 1.4-3.8x behind Apache,
Jetty and OkHttp, so use the pooled one for a host you call often); and JSON through a
String when the text is full of non-ASCII. All figures, the feature comparisons and the
method: docs/BENCHMARKS.md.
Building
mvn install
Test classes are published as a second artifact (nl.rutilo:silver:tests) —
they hold the fakes a consumer needs to test against Silver, such as
FakeModbusDevice.
Documentation
CLAUDE.md in this repository is the fullest description of the architecture
and conventions. The examples package holds worked
examples (src/main/java/nl/rutilo/silver/examples); they are compiled and
tested with the build, and published in the sources jar, not the jar itself.
docs/BENCHMARKS.md compares Silver with the libraries it
replaces: speed, memory and allocation, what each one can and cannot do, and how it
was measured.