Cloud Tech by Victor

Search

30 results for “redis

Search results

Backend

Redis Caching Patterns

Cache-aside, write-through, and write-behind explained, plus the TTL, stampede, and invalidation pitfalls that show up once Redis caching hits real traffic.

Databases

Redis vs Memcached

How Redis and Memcached differ in data structures, persistence, clustering, and threading, and which cache fits which workload.

Redis Caching Patterns

What is cache stampede and how do you prevent it?

A cache stampede happens when a popular cache key expires and many concurrent requests all miss at once, each falling through to hit the (often slow) origin, database or upstream API, simultaneously, sometimes overwhelming it. Common mitigations: a short-lived lock so only one request repopulates the cache while others wait or serve stale data (the "thundering herd" lock pattern), staggered/jittered TTLs so keys do not all expire at the same instant, and serving stale-while-revalidate, returning the expired value immediately while refreshing it in the background.

Redis Caching Patterns

What is the difference between cache-aside and write-through caching?

Cache-aside (lazy loading): the application checks the cache first; on a miss it reads from the database, then writes the result into the cache. Writes go to the database only, so the cache can go stale until the next miss or an explicit invalidation. Write-through: every write goes to the cache and the database together (usually the cache write happens synchronously as part of the write path), so the cache is always in sync with the database, at the cost of extra write latency on every mutation.

Redis Caching Patterns

Why can naive cache invalidation cause a race condition?

If a write invalidates (deletes) a cache key and then updates the database, a concurrent read between those two steps can repopulate the cache with the old value right after it was deleted, leaving stale data cached until the next TTL expiry or invalidation. Ordering matters: update the database first, then invalidate the cache, and even then, a very unlucky interleaving with a concurrent cache-aside read can still occur, which is why short TTLs are used as a safety net rather than relying on invalidation alone for strict consistency.

React Hooks Deep Dive

Why does React require hooks to be called in the same order on every render?

React does not track hook state by name; it tracks it by call order in a linked list attached to the component's fiber. On each render, React walks that list and matches the nth useState call to the nth stored slot. If a hook is called conditionally (inside an if, or after an early return), the call order can shift between renders, and React ends up reading the wrong slot for a given hook; this is exactly why hooks cannot be called inside conditionals or loops.

React Rendering & Reconciliation

Does React mutate the DOM during the render step, and if not, when does the actual DOM update happen?

No. Rendering is a pure calculation, React calls component functions to figure out what the new JSX should be and diffs it against the previous render, but no DOM node is touched during this step. The actual DOM update happens in a separate commit step afterward, where React applies only the minimal necessary changes based on what actually differs from the previous render, appending everything on the very first render, but patching selectively on every re-render after that. This separation is why an uncontrolled `<input>`'s typed value survives a re-render of its parent: React only touches DOM nodes that actually changed, and leaves everything else alone.

Git Fundamentals

What is the difference between the working directory, the staging area, and a commit in Git?

The working directory is the actual files on disk, whatever state you've left them in. The staging area (the "index") is a snapshot of exactly what will go into the next commit; `git add` copies changes from the working directory into it, one file or hunk at a time, which is why you can commit only part of what you've changed. A commit is a permanent, immutable snapshot of the staging area at the moment you ran `git commit`, plus a pointer to its parent commit, which is what forms the project's history graph. Understanding that staging is a separate, explicit step - not just "what's changed" - explains why `git status` shows both staged and unstaged changes for the same file.

React Hooks Deep Dive

When should you reach for useMemo or useCallback, and when is it wasted effort?

They are worth it when a computation is genuinely expensive, or when the memoized value/function is a dependency of another hook, or a prop to a component wrapped in React.memo, in those cases, an unnecessary new reference on every render causes real extra work downstream. For cheap computations with no memoized consumer, useMemo/useCallback add overhead (the comparison itself, plus code complexity) without a measurable benefit, profile before reaching for them by default.

Recursion & the Call Stack

What does Python's recursion limit actually protect against, and is it just an arbitrary language-level rule?

It protects the real, underlying C stack the Python interpreter itself runs on, each level of recursion consumes real stack memory, and without a limit, sufficiently deep (or infinite) recursion would exhaust that stack and crash the interpreter process entirely, a hard C-level failure, not a clean Python exception. The limit converts that hard crash into a catchable `RecursionError` raised well before the actual stack is exhausted, which is exactly why it exists, a controlled failure mode is far better than an uncontrolled process crash, not an arbitrary restriction on how "should" write code.

Azure Active Directory (Entra ID)

What is a managed identity, and what problem does it solve compared to a service principal with a client secret?

A managed identity is an Entra ID identity automatically managed by Azure for a resource (a VM, an App Service, a Function), with credentials that Azure handles entirely, no client secret is ever stored, retrieved, or rotated by the application. A traditional service principal with a client secret requires that secret to be stored somewhere (a config file, a key vault) and rotated manually or via automation, which is itself a credential-management burden and a leak risk. Managed identities remove that burden for the common case of "this Azure resource needs to authenticate to another Azure service," which is why they're preferred whenever the workload runs on Azure compute.

Dynamic Programming

What does NIST's own definition of dynamic programming actually say the technique does, and what problem does it solve?

NIST's Dictionary of Algorithms and Data Structures defines dynamic programming as an algorithmic technique to "solve an optimization problem by caching subproblem solutions (memoization) rather than recomputing them." The problem it solves is redundant recomputation: when a naive recursive solution calls itself with the same subproblem arguments repeatedly (matrix-chain multiplication, longest common subsequence, and similar problems are the examples NIST gives), that same subproblem gets solved from scratch every single time it recurs, and caching the first result lets every later occurrence be a lookup instead of a full recomputation.

Message Queues & Event-Driven Architecture

What is a visibility timeout, and what problem does it solve that simply having multiple consumers poll a queue would create?

When a consumer receives a message, the queue doesn't delete it immediately, it starts a visibility timeout during which that message is hidden from other consumers, so a second consumer polling the same queue won't also pick up and process the same message concurrently. The consumer is expected to finish processing and explicitly delete the message before the timeout expires; if it does, the message never reappears. Without this mechanism, multiple consumers competing for messages would routinely double-process the same one, exactly the race condition visibility timeouts exist to prevent.

AWS Storage

What is the difference between durability and availability in S3, and why does it matter when picking a storage class?

Durability is the probability that a stored object is not lost over a year, and S3 Standard, Standard-IA, and every Glacier class are all designed for the same 99.999999999% (11 nines) durability. Availability is how often the object can actually be successfully retrieved on demand, and that number does vary by class, 99.99% for Standard down to 99.5% for One Zone-IA. It matters because a cheaper class is not automatically a less durable one, S3 One Zone-IA is exactly as durable as Standard-IA per object, but it is not resilient to the loss of its single Availability Zone at all, since it isn't replicated across multiple zones the way every multi-AZ class is.

Azure Networking

What is an Azure Virtual Network (VNet) and how does it relate to subnets?

A VNet is an isolated network within Azure, scoped to a subscription and region, defined by an address space (a CIDR block). Subnets divide that address space into smaller segments, and every resource with networking (a VM, an App Service with VNet integration) is deployed into a specific subnet, not directly into the VNet itself. Subnets are also where Network Security Groups and route tables actually attach, so subnet design is where most Azure network segmentation decisions get made.

Dynamic Programming

Why does a naive recursive Fibonacci function run in exponential time, and how does memoization fix that specifically?

Naive recursive `fib(n) = fib(n-1) + fib(n-2)` recomputes the exact same subproblem enormous numbers of times, `fib(n-2)` gets computed once directly and once again inside the `fib(n-1)` call, and this duplication compounds recursively, producing roughly 2^n total calls. Memoization caches each `fib(k)` result the first time it's computed, so every subsequent call with the same `k` becomes an O(1) cache lookup instead of a full recursive recomputation, collapsing the total distinct work down to O(n), one computation per distinct subproblem instead of an exponential number of repeated ones.

Kubernetes Fundamentals

Why can't you rely on a Pod's IP address for service discovery?

Pods are ephemeral by design, Kubernetes kills and recreates them constantly (failed health checks, node drains, rolling deployments, autoscaling), and every new Pod gets a brand-new IP address. Hardcoding or caching a Pod IP breaks the moment that Pod is replaced. A Service solves this by providing a stable virtual IP and DNS name that always routes to whichever Pods currently match its label selector, regardless of how many times the underlying Pods have been replaced.

Linux Networking

A socket shows up in the LISTEN state versus ESTABLISHED. What is actually different about what that socket is doing?

LISTEN means a server-side socket is bound to a port and passively waiting to accept incoming connection requests, it isn't attached to any specific remote peer yet. ESTABLISHED means a full connection has completed its handshake and is actively associated with a specific remote address and port, data can flow in both directions. Seeing a service you expect to be running not show a LISTEN socket on its expected port is usually the very first, most direct signal that the service isn't actually up or isn't bound where you think it is.

LLM Fundamentals: Tokens, Context Windows & Sampling

A request's input already exceeds the model's context window before generation even starts. What happens, versus a request that only exceeds the limit once output is generated?

If the input alone already exceeds the context window, the API rejects the request upfront with a 400 error, generation never starts at all. If the input fits but input tokens plus the requested max output tokens could exceed the window, current models accept the request and generate as far as they can; if generation actually reaches the window limit before finishing, it stops early with a specific stop reason indicating the context window was exhausted, rather than silently truncating or erroring out mid-response. The distinction matters operationally: the first case is a fixable request-construction bug, the second is a signal to reduce the requested output length or the accumulated conversation history.

Platform Engineering Fundamentals

How does platform engineering differ from traditional DevOps or a shared infrastructure team?

Traditional DevOps distributes infrastructure responsibility to product teams ("you build it, you run it"), while a shared infrastructure team typically operates as a ticket-driven service, product teams request resources and wait. Platform engineering treats the internal platform itself as a product, with its own users (the engineers building on it) and a deliberate design goal: reduce cognitive load by providing paved, self-service paths for common needs, rather than either forcing every team to become infrastructure experts or making them wait on a queue. The platform team builds golden paths; product teams self-serve through them.

Python Data Structures

Why is checking membership with `in` fast on a set or dict but slow on a list?

Sets and dicts are implemented as hash tables, checking whether a value exists means computing its hash and looking up that bucket directly, an O(1) average-case operation regardless of how many items are stored. A list has no such index; checking membership means scanning entries one by one until a match is found or the list ends, an O(n) operation that gets slower as the list grows. For any code doing repeated membership checks against a growing collection, using a set instead of a list is often the single biggest easy performance fix available.

SQL Joins & Query Planning

PostgreSQL's documentation says it's "impossible to suppress nested-loop joins entirely" even with enable_nestloop off. What does that tell you about relying on planner hints to force a specific join algorithm?

That specific guarantee is documented only for `enable_nestloop`: turning it off only discourages the planner by making nested loops look artificially expensive in cost estimation, it can't hard-disable them, because for some queries a nested loop is the only viable plan at all (for example, certain correlated subquery shapes), so the planner will still use one if it must. `enable_hashjoin` and `enable_mergejoin` don't carry that same caveat, disabling either one actually can prevent the planner from choosing that join type, since a nested loop (or the other remaining method) is always available as a fallback plan. In practice, though, all three settings are best treated as a debugging/diagnostic tool for understanding planner behavior, not a reliable production mechanism for forcing a specific join algorithm, the actual fix for a bad plan is almost always better statistics (via `ANALYZE`) or a better index, not overriding the planner's method choice.

Testing Python with pytest

What is a pytest fixture, and what problem does it solve compared to manual setup/teardown?

A fixture is a function decorated with `@pytest.fixture` that provides a reusable piece of test setup (a database connection, a temp directory, a configured client) which pytest automatically injects into any test function that declares it as a parameter. It solves the same problem as `unittest`'s `setUp`/`tearDown` methods, but as small, composable, independently reusable functions rather than one monolithic method per test class, a test can request exactly the fixtures it needs, and fixtures can depend on other fixtures, building up complex setup from simple, testable pieces.

Blog

How to Install Active Directory Domain Services (AD DS) on Windows Server using Hyper-V (Step-by-Step Guide)

Active Directory Domain Services (AD DS) remains one of the most essential building blocks in enterprise IT. Whether you're managing on‑prem infrastructure, hybrid cloud environments, or lab setups, understanding how to deploy and configure AD DS is a core skill for any cloud infrastructure or syst…

Backend

LLM Evaluation & Reducing Hallucinations

Why "it feels better" isn't a shippable justification for a prompt change, what an LLM-graded eval actually measures, and why explicitly allowing "I don't know" is one of the most effective, cheapest hallucination fixes available.

Embeddings & Vector Search

What does an embedding actually represent, and what does the distance between two embeddings measure?

An embedding is a vector, a list of floating-point numbers, produced by a model that maps a piece of text into that vector space such that texts with similar meaning end up positioned close together. The distance between two embeddings, typically measured with cosine similarity, quantifies how related the two original texts are: a small distance (high cosine similarity) means the model judged them semantically close, even if they don't share any of the same words, and a large distance means they're unrelated. This is the property that makes embeddings useful for search and clustering: comparison happens on meaning, encoded numerically, rather than on literal text overlap.

Linux Filesystem Hierarchy & Permissions

What do the three digits in a chmod octal mode like 644 or 755 actually mean, and what does a leading fourth digit add?

Each of the three digits is a sum of read (4), write (2), and execute (1), in order for the owner, the group, and everyone else; 644 means the owner gets read+write (4+2), while group and others get read-only (4). 755 means the owner gets read+write+execute (4+2+1), and group/others get read+execute (4+1), the common mode for an executable or a directory that others need to traverse. An optional leading fourth digit sets setuid (4), setgid (2), and the sticky bit (1); setuid/setgid make a program run with its owner's or group's privileges rather than the caller's, and the sticky bit on a directory (classically 1777 on /tmp) restricts file deletion to each file's own owner even though the directory itself is world-writable.

Python Web Frameworks Overview

What is the core philosophical difference between Flask and Django?

Flask is a microframework; it provides routing and request/response handling and deliberately leaves everything else (ORM, admin panel, authentication, forms) to be chosen and added by the developer. Django is batteries-included; it ships with an ORM, an admin interface, an authentication system, and a forms library as an integrated whole, with strong conventions about how a project should be structured. Flask trades built-in structure for flexibility; Django trades flexibility for a consistent, fully-equipped starting point. Neither is strictly better, the right choice depends on whether a project benefits more from Django's conventions or needs the freedom to pick its own pieces.

Testing Python with pytest

What is fixture scope, and why is choosing the wrong one a common source of confusing test failures?

Scope (`function`, `class`, `module`, `session`) controls how often a fixture is torn down and recreated, `function` scope (the default) creates a fresh instance for every test, while `session` scope creates it once for the entire test run and shares it across every test that requests it. Choosing a broader scope than a fixture's state can safely support is a common bug: a `session`-scoped fixture holding mutable state (like a database connection with data inserted by one test) leaks that state into every other test sharing it, causing tests to pass or fail depending on run order, a difficult, non-deterministic failure to debug.

The CAP Theorem

MongoDB can be configured to behave more like a CP system or more like an AP system. What settings make that choice, and what are they actually trading?

Write concern and read preference are the actual levers: a write concern requiring acknowledgment from a majority of replicas favors consistency, a write isn't considered successful until enough nodes agree, at the cost of availability if too many nodes are unreachable during a partition. A looser write concern, or reading from secondaries that might lag behind the primary, favors availability, operations keep succeeding even when full replica agreement isn't achievable, at the cost of potentially reading or acknowledging data that isn't fully consistent across the cluster yet. This is exactly the CP-versus-AP trade-off CAP describes, expressed as a concrete, tunable configuration rather than an abstract theorem.

Search results for “redis” | Cloud Tech by Victor