Posts
Java backend from the fundamentals to system design: one topic per post, straight to the mechanics, with runnable examples.
- posts
- 176
- topics
- 71
- hours of reading
- 23
176 postsShowing 1–24 of 176 posts
- System DesignLLM API cost and latency: tokens, prompt caching, batching and model choiceLLM bills and p99 latency grow with tokens, not with request counts. How to estimate cost per task, keep the prefix stable so prompt caching hits, batch work that isn't urgent, pick a smaller model only with quality measured, and set per-user token budgets.#llm#token#prompt-caching
- System DesignAn AI-agent-friendly codebase: AGENTS.md, fast tests, machine-checked conventionsAn agent codes only as well as its feedback loop: build and test commands written down in AGENTS.md, module tests under a minute, architecture conventions checked by ArchUnit instead of review comments, clear module boundaries. Which rule goes where.#ai-agent#agents-md#archunit
- System DesignEvaluating LLM output: golden sets, LLM-as-judge and prompt regressionsUnit tests can't assert on free text: build a golden set, layer hard checks, reference comparison and LLM-as-judge, calibrate the judge against human labels, and stop a new prompt from degrading answers in CI.#llm-evaluation#llm-as-judge#golden-set
- System DesignReviewing AI-written code: a risk-based checklist and automated checksAI-written PRs are long, confident and plausible. How to let machines catch what machines can (compiling, tests, ArchUnit, mutation testing, dependency scans) and keep humans on invariants, permissions, migrations and failure behaviour; with a checklist by risk level.#code-review#ai-generated-code#archunit
- System DesignCalling an LLM from the backend: timeouts, retries, streaming and fallbacksAn LLM call is a slow, flaky third party that bills per token. How to set a deadline, retry the right status codes, stream over SSE, stop the LLM from taking the whole service down, and review AI-written integration code.#llm#timeout#retry-backoff
- System DesignTool calling and agents in the backend: function calling, idempotency and least privilegeThe model only proposes, your code executes: design tools as public APIs called by an untrusted client, authorise by the user rather than the model, keep tools idempotent when the agent calls again, require confirmation for irreversible actions, and cap the loop.#tool-calling#function-calling#ai-agent
- System DesignObservability for LLM calls: traces, tokens, cost and qualityWhich request burned 40,000 tokens, which prompt version made answers worse: measuring an LLM call as an expensive, erratic dependency, following the OpenTelemetry GenAI semantic conventions, tagging feature and prompt version, without leaking user content.#observability#opentelemetry#llm
- System DesignPrompt injection and LLM application securityAn LLM can't separate instructions from data, so untrusted text can become instructions. How to design so a fooled model still can't do harm: tools with the user's permissions, confirmation before irreversible actions, output treated as untrusted data, exfiltration channels closed; with the 2026 OWASP Top 10 for LLM applications.#prompt-injection#llm-security#owasp
- System DesignRAG with PostgreSQL and pgvector: embeddings, HNSW indexes and permission filteringAnswering from internal documents without leaking rows the user may not see: embeddings and chunks, pgvector's HNSW index, why filtering after the index loses results, why permissions belong in the SQL rather than the prompt, and how to review RAG code written by AI.#rag#pgvector#embedding
- System DesignHybrid search: full-text, vectors and rerankingKeyword search misses synonyms, vector search misses exact codes: combine both branches with Reciprocal Rank Fusion right inside PostgreSQL, rerank the top 50 with a cross-encoder, and measure with recall@k instead of gut feeling.#hybrid-search#full-text-search#vector-search
- Spring BootMiniWallet: one e-wallet pet project that grows with the backend roadmapThe plan for MiniWallet, the project behind the site's hands-on labs: why an e-wallet, the target architecture, six phases from plain Java to several services, an optional buy-now-pay-later phase, where WebFlux fits, and the rules for working with agents so you write the core yourself.#pet-project#e-wallet#spring-boot
- Database & SQLSubqueries, CTEs, recursive CTEs, window functions and temporary tablesWhen a subquery re-runs for every row, when a CTE is inlined or materialized, walking trees with WITH RECURSIVE and stopping cycles, window functions whose default frame gives wrong answers, top-N per group, de-duplication, when you need a temporary table; measured on PostgreSQL 18 with 1 million rows, plus how to review SQL an AI wrote.#cte#recursive-cte#window-function
- Advanced JavaGarbage collection in the JVM: G1, ZGC, reading GC logs and diagnosing OutOfMemoryErrorWhy a Java app freezes for hundreds of milliseconds or dies with OutOfMemoryError while the heap looks free; how the GC decides what is garbage, choosing Serial, Parallel, G1, ZGC or Shenandoah on JDK 25 with measurements, reading GC logs, the six kinds of OOM, finding memory leaks in production and reviewing AI-proposed JVM flags.#garbage-collection#g1#zgc
- Advanced JavaInside the JVM: runtime memory areas, class loading and ClassLoadersWhere a running Java program lives in memory: heap, stack, metaspace, PC register, code cache; how classes are loaded, linked and initialized; the ClassLoader tree, parent delegation, why the same class name can be two different types, and ClassLoader leaks.#jvm#classloader#metaspace
- DevOps & OperationsKubernetes for backend developers: architecture, Pods, Services, ConfigMaps, autoscaling and debugging failing podsHow Kubernetes runs on desired state and reconcile loops, what the control plane and nodes contain, how Pods, Deployments, StatefulSets and Jobs differ, ClusterIP/NodePort/LoadBalancer Services, Ingress and the Gateway API, ConfigMaps and Secrets, requests/limits and QoS, how the HPA computes replica counts, and a checklist for Pending, ImagePullBackOff, CrashLoopBackOff and OOMKilled.#kubernetes#pod#service
- Spring BootDistributed job scheduling: Quartz clustering, misfires and splitting big jobs across workersQuartz's Job, JobDetail, Trigger and JobStore model, @DisallowConcurrentExecution and @PersistJobDataAfterExecution, how a Quartz cluster uses the JDBC JobStore and the QRTZ_LOCKS row lock, misfires and catch-up runs, Spring Boot configuration, and how to turn a two-day job emailing 10 million users into leased chunks processed in parallel.#quartz#job-scheduling#distributed-systems
- DevOps & OperationsLogging for backends: log levels, structured logs, MDC and a centralized log pipeline with ELK or LokiWhat to log at which level, turning on the JSON logging built into Spring Boot 3.4+ (ECS, Logstash, GELF), carrying traceId through MDC and thread pools, never leaking passwords or tokens, shipping logs via stdout → Fluent Bit → Elasticsearch/Kibana or Loki, or OTLP, with how to estimate volume and how to review logging config written by AI.#logging#elk#structured-logging
- Advanced JavaReflection, annotations and annotation processors: how Java frameworks read your codeThe reflection API and its cost, setAccessible's limits since JDK 17, dynamic proxies, @Retention and @Inherited, annotation processors that generate code at compile time, how Lombok differs from MapStruct, and choosing run time or compile time.#reflection#annotation#annotation-processor
- System DesignPrimary–replica replication and read/write splitting: replication lag, read-your-writes and failoverPrimary–replica on MySQL and PostgreSQL: async, semi-sync and sync; replication-lag bugs, four ways to keep read-your-writes, read/write routing in Spring Boot, and failover without split-brain.#replication#read-replica#replication-lag
- Advanced JavaSOLID by problem: five ways to lower the cost of change, and when you don't need themSOLID ordered by the problem each principle prevents: one change dragging in several groups (SRP by actor), adding a variant means editing running code (OCP, or sealed + switch), a new implementation silently breaking callers (Liskov, checked by contract tests), clients tied to methods they don't use (ISP), business rules tied to infrastructure (DIP vs DI); the cost of overdoing it and how to review designs an AI proposes.#solid#srp#liskov-substitution
- Spring BootSpring AOP and BeanPostProcessor: proxies, pointcuts and advice orderSpring AOP runs on proxies created by a BeanPostProcessor: aspects, pointcuts, the five advice types and their order measured on Spring 7, several aspects with @Order, how AspectJ differs, BeanPostProcessor versus BeanFactoryPostProcessor, and why a bean injected into a BPP loses its proxy.#spring-aop#proxy#bean-post-processor
- DevOps & OperationsSpring Boot Actuator: health, metrics and production monitoringActuator run on Spring Boot 4.0.5: which endpoints are open by default, how to expose and protect them, a custom health indicator and liveness/readiness groups for Kubernetes, Micrometer metrics (timers, percentiles, cardinality), changing log levels at runtime, and which numbers to alert on.#spring-boot#actuator#micrometer
- System DesignService discovery, central config and gateways: platform or library (Spring Cloud)Why you can't hard-code host:port and per-instance settings; the four jobs every multi-service system must solve (discovery, shared config, one front door, fault tolerance) and whether Kubernetes/a mesh or an in-app library should do them. Spring Cloud (Config, Eureka, LoadBalancer, Gateway, CircuitBreaker) with a real lab; how to review AI-written config.#spring-cloud#eureka#api-gateway
- Java CoreCreating objects properly: static factories, builders, singletons and why "only one instance" keeps breakingA constructor makes the caller decide parameter order, whether a new object is created and which concrete class it is. When to move those decisions into a static factory, a builder or a container; what scope a singleton really has and four ways to break one; needless objects, obsolete references, Cleaner instead of finalize; how to review AI-written builders and singletons.#static-factory#builder-pattern#singleton