⚡ Ultra-fast asynchronous name resolution for the FastJava ecosystem.
FastDNS combines a stable asynchronous API with a local TTL cache for crawlers, service clients, telemetry gateways and socket pools. It uses the portable JDK resolver today while reserving a native Windows DnsQueryEx, DoH and DoT backend for high-concurrency workloads.
Run the DNS Cache Demo | Run the Resolver Benchmark
import fastdns.FastDNS;
public class Example {
public static void main(String[] args) {
FastDNS.resolve("example.com")
.thenAccept(address -> System.out.println("Resolved: " + address));
}
}- Why FastDNS?
- Quick Start
- Features
- Real-World Scenarios
- Performance Benchmarks
- API Quick Reference
- Technical Examples & Hero Demos
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Synchronous hostname resolution becomes a bottleneck when crawlers, telemetry clients or socket pools open many endpoints:
- Blocking lookups: A resolver call can hold a worker while the operating system waits for a response.
- Repeated work: Stable service names are resolved again even when a recent answer is still valid.
- Connection coupling: Network code becomes harder to scale when resolution and socket setup share a blocking path.
FastDNS addresses this with a small resolver facade:
- Asynchronous completion: Resolution returns a
CompletableFuturefor natural fan-out. - TTL-aware cache: Successful answers are reused until the caller-selected expiry time.
- Native-ready providers:
DnsQueryEx, DoH and DoT can replace the fallback without changing callers.
- ⚡ Asynchronous resolution: Resolve many service names without blocking crawler or client workers.
- 🗃️ TTL-aware cache: Reuse successful answers with a caller-selected lifetime.
- 🧵 Thread-safe facade: Concurrent lookups share a predictable cache contract.
- 🪟 Native-ready backend: Designed for Windows
DnsQueryEx, DoH and DoT integration.
- Web crawling: Resolve thousands of crawler endpoints without blocking worker threads.
- FastNet startup: Resolve service endpoints before opening socket connections.
- Microservice clients: Reuse short-lived DNS answers during burst traffic.
- Telemetry: Avoid repeated resolver work for stable device gateways.
FastDNS includes a cache demo and a repeated-lookup benchmark to expose resolver overhead before native DnsQueryEx integration.
| Metric / Resolution Type | Current Java Fallback | Native Target |
|---|---|---|
| Cached lookup | Measured by benchmark | Atomic native cache |
| Cold lookup | JDK resolver | DnsQueryEx |
| Secure lookup | Provider-dependent | DoH / DoT |
The benchmark measures repeated local lookups. Native latency and cache figures are reported only after the platform resolver backend is integrated.
The optimized local benchmark completed 1,000 cached localhost lookups in 12.25 ms after clearing the cache; in-flight deduplication also prevents duplicate concurrent resolver work for the same hostname:
run-benchmark.bat -> fastdns.ResolverBenchmark
The result is machine-dependent; run the launcher again when comparing TTL, cache or native DnsQueryEx changes.
| Method | Description |
|---|---|
| Method | Description |
| -------- | ------------- |
resolve(hostname) |
Resolves a hostname asynchronously using the default TTL. |
resolve(hostname, ttlMillis) |
Resolves and caches with a caller-selected TTL. |
clearCache() |
Removes all cached answers. |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Crawler Endpoint Cache | DnsCacheDemo.java | run-demo.bat |
Compares the first lookup with a cached service endpoint lookup. |
| Resolver Cache Throughput | ResolverBenchmark.java | run-benchmark.bat |
Measures repeated cached lookups for a high-volume client. |
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastDNS</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastDNS:0.1.0'
}Download the latest FastDNS JAR from the GitHub releases page.
- COMPILE.md: Full compilation guide and launcher instructions.
- REFERENCE.md: Resolver and cache contract.
- PHILOSOPHY.md: Async and cache principles.
- ROADMAP.md: Native resolver milestones.
- CHANGELOG.md: Version history.
| Platform | Status |
|---|---|
| Windows 10/11 x64 | Native DnsQueryEx planned |
| Linux | Java fallback |
| macOS | Java fallback |
MIT License — See LICENSE for details.
- FastNet — Asynchronous network transport
- FastTLS — Secure endpoint transport
- FastWebSpider — Parallel crawling
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋