Redis was running a large production service with about **10 million monthly active users**. Every record in Redis was a **JSON-serialized Pydantic model** It looked clean and convenient – until it started to hurt. At scale, JSON stops being a harmless convenience and becomes a silent tax on memory.Redis was running a large production service with about **10 million monthly active users**. Every record in Redis was a **JSON-serialized Pydantic model** It looked clean and convenient – until it started to hurt. At scale, JSON stops being a harmless convenience and becomes a silent tax on memory.

JSON Was Killing Our Redis Memory. Switching Serialization Made It 7× Smaller.

2025/10/30 14:08

We were running a large production service with about 10 million monthly active users, and Redis acted as the main storage for user state. Every record in Redis was a JSON-serialized Pydantic model. It looked clean and convenient – until it started to hurt.

As we grew, our cluster scaled to five Redis nodes, yet memory pressure only kept getting worse. JSON objects were inflating far beyond the size of the actual data, and we were literally paying for air – in cloud invoices, wasted RAM, and degraded performance.

At some point I calculated the ratio of real payload to total storage, and the result made it obvious that we couldn’t continue like this:

14,000 bytes per user in JSON → 2,000 bytes in a binary format

A 7× difference. Just because of the serialization format.

That’s when I built what eventually became PyByntic – a compact binary encoder/decoder for Pydantic models. And below is the story of how I got there, what didn’t work, and why the final approach made Redis (and our wallets) a lot happier.

Why JSON Became a Problem

JSON is great as a universal exchange format. But inside a low-level cache, it turns into a memory-hungry monster:

  • it stores field names in full
  • it stores types implicitly as strings
  • it duplicates structure over and over
  • it’s not optimized for binary data
  • it inflates RAM usage to 3–10× the size of the real payload

When you’re holding tens of millions of objects in Redis, this isn’t some academic inefficiency anymore – it’s a real bill and an extra server in the cluster. At scale, JSON stops being a harmless convenience and becomes a silent tax on memory.

What Alternatives Exist (and Why They Didn’t Work)

I went through the obvious candidates:

| Format | Why It Failed in Our Case | |----|----| | Protobuf | Too much ceremony: separate schemas, code generation, extra tooling, and a lot of friction for simple models | | MessagePack | More compact than JSON, but still not enough – and integrating it cleanly with Pydantic was far from seamless | | BSON | Smaller than JSON, but the Pydantic integration story was still clumsy and not worth the hassle |

All of these formats are good in general. But for the specific scenario of “Pydantic + Redis as a state store” they felt like using a sledgehammer to crack a nut – heavy, noisy, and with barely any real relief in memory usage.

I needed a solution that would:

  • drop into the existing codebase with just a couple of lines
  • deliver a radical reduction in memory usage
  • avoid any extra DSLs, schemas, or code generation
  • work directly with Pydantic models without breaking the ecosystem

What I Built

So I ended up writing a minimalist binary format with a lightweight encoder/decoder on top of annotated Pydantic models. That’s how PyByntic was born.

Its API is intentionally designed so that you can drop it in with almost no friction — in most cases, you just replace calls like:

model.serialize() # replaces .model_dump_json() Model.deserialize(bytes) # replaces .model_validate_json()

Example usage:

from pybyntic import AnnotatedBaseModel from pybyntic.types import UInt32, String, Bool from typing import Annotated class User(AnnotatedBaseModel): user_id: Annotated[int, UInt32] username: Annotated[str, String] is_active: Annotated[bool, Bool] data = User( user_id=123, username="alice", is_active=True ) raw = data.serialize() obj = User.deserialize(raw)

Optionally, you can also provide a custom compression function:

import zlib serialized = user.serialize(encoder=zlib.compress) deserialized_user = User.deserialize(serialized, decoder=zlib.decompress)

Comparison

For a fair comparison, I generated 2 million user records based on our real production models. Each user object contained a mix of fields – UInt16, UInt32, Int32, Int64, Bool, Float32, String, and DateTime32. On top of that, every user also had nested objects such as roles and permissions, and in some cases there could be hundreds of permissions per user. In other words, this was not a synthetic toy example — it was a realistic dataset with deeply nested structures and a wide range of field types.

The chart shows how much memory Redis consumes when storing 2,000,000 user objects using different serialization formats. JSON is used as the baseline at approximately 35.1 GB. PyByntic turned out to be the most compact option — just ~4.6 GB (13.3% of JSON), which is about 7.5× smaller. Protobuf and MessagePack also offer a noticeable improvement over JSON, but in absolute numbers they still fall far behind PyByntic.

Let's compare what this means for your cloud bill:

| Format | Price of Redis on GCP | |----|----| | JSON | $876/month | | PyByn­tic | $118/month | | MessagePack | $380/month | | BSON | $522/month | | Protobuf | $187/month |

This calculation is based on storing 2,000,000 user objects using Memorystore for Redis Cluster on Google Cloud Platform. The savings are significant – and they scale even further as your load grows.

Where Does the Space Savings Come From?

The huge memory savings come from two simple facts: binary data doesn’t need a text format, and it doesn’t repeat structure on every object. In JSON, a typical datetime is stored as a string like "1970-01-01T00:00:01.000000" – that’s 26 characters, and since each ASCII character is 1 byte = 8 bits, a single timestamp costs 208 bits. In binary, a DateTime32 takes just 32 bits, making it 6.5× smaller with zero formatting overhead.

The same applies to numbers. For example, 18446744073709551615 (2^64−1) in JSON takes 20 characters = 160 bits, while the binary representation is a fixed 64 bits. And finally, JSON keeps repeating field names for every single object, thousands or millions of times. A binary format doesn’t need that — the schema is known in advance, so there’s no structural tax on every record.

Those three effects – no strings, no repetition, and no formatting overhead – are exactly where the size reduction comes from.

Conclusion

If you’re using Pydantic and storing state in Redis, then JSON is a luxury you pay a RAM tax for. A binary format that stays compatible with your existing models is simply a more rational choice.

For us, PyByntic became exactly that — a logical optimization that didn’t break anything, but eliminated an entire class of problems and unnecessary overhead.

GitHub repository: https://github.com/sijokun/PyByntic

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact [email protected] for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Superstate Launches SEC‑Approved Tokenized Share Issuance on Ethereum and Solana

Superstate Launches SEC‑Approved Tokenized Share Issuance on Ethereum and Solana

Superstate introduced a new pathway that brings public equity issuance onto blockchain networks through a regulated structure. The firm now enables SEC-registered companies to sell new tokenized shares directly to investors on Ethereum and Solana. The move signals a shift toward faster capital formation as firms search for more efficient fundraising channels. Moreover, the development arrives as U.S. regulators accelerate experiments that merge traditional finance with blockchain infrastructure. Consequently, the launch positions Superstate at the center of efforts to modernize how public companies raise money and maintain shareholder records.Direct Issuance Targets Faster Funding and Instant SettlementThe Direct Issuance Program lets issuers receive capital in stablecoins while investors receive tokenized shares in real time. This structure allows companies to manage shareholder updates instantly through Superstate’s regulated transfer agent system. Additionally, the program supports existing share classes or new digital-only classes, giving companies more flexibility in how they engage investors.Superstate expects the first offerings to launch in 2026. The firm argues that companies need issuance rails that match global capital flows and deliver immediate settlement. Hence, the appeal of stablecoin-based transactions grows as markets demand more certainty and speed. The approach may also help smaller issuers reach investors who prefer blockchain-based assets with transparent lifecycle tracking.Regulators Accelerate Blockchain ExperimentsRegulators under the Trump administration encourage more crypto-financial innovation, which strengthens interest in tokenized securities. Both the SEC and CFTC now advance guidelines that reduce uncertainty around digital issuance. Moreover, large issuers and fintech firms continue to test onchain models that integrate with compliance tools and custodial systems.Earlier efforts by Galaxy and Sharplink involved tokenizing existing shares for onchain holding. However, those initiatives did not raise new capital. Superstate now extends that foundation by enabling primary issuance that interacts directly with blockchain liquidity.Programmable Securities Unlock New Use CasesTokenized shares issued through the program can include programmable features that update governance or distribution rules automatically. Besides, the digital structure allows integrations with onchain settlement, portfolio management, and institutional custody providers. These features may attract investors seeking assets that combine regulatory protection with efficient blockchain execution.Superstate intends to open its offering to both retail and institutional buyers after KYC checks. Consequently, the initiative may reshape how issuers approach capital formation and how investors access regulated digital securities.
Share
Coinstats2025/12/11 03:16
XRP triggert patroon dat voorafging aan eerdere 7000% stijging

XRP triggert patroon dat voorafging aan eerdere 7000% stijging

i Kennisgeving: Dit artikel bevat inzichten van onafhankelijke auteurs en valt buiten de redactionele verantwoordelijkheid van BitcoinMagazine.nl. De informatie is bedoeld ter educatie en reflectie. Dit is geen financieel advies. Doe zelf onderzoek voordat je financiële beslissingen neemt. Crypto is zeer volatiel er zitten kansen en risicos aan deze investering. Je kunt je inleg verliezen. XRP laat opnieuw hetzelfde koerspatroon zien dat in 2017 leidde tot een stijging van meer dan 7000%. De nieuwe vergelijking die rondgaat op X laat zien dat de huidige structuur bijna een-op-een lijkt op die van toen. Wanneer gaat Ripple stijgen en hoe serieus is deze technische setup? Check onze Discord Connect met "like-minded" crypto enthousiastelingen Leer gratis de basis van Bitcoin & trading - stap voor stap, zonder voorkennis. Krijg duidelijke uitleg & charts van ervaren analisten. Sluit je aan bij een community die samen groeit. Nu naar Discord Ripple koers toont dezelfde golven als in 2017 De grafieken van 2017 en nu lijken opvallend veel op elkaar. Je ziet dezelfde golfbewegingen, dezelfde rustfase en dezelfde neerwaartse afronding van de vierde golf. In 2017 volgde daarna de grote doorbraak. 🚨𝐁𝐑𝐄𝐀𝐊𝐈𝐍𝐆: 𝐗𝐑𝐏 𝐉𝐮𝐬𝐭 𝐄𝐧𝐭𝐞𝐫𝐞𝐝 𝐭𝐡𝐞 𝐒𝐚𝐦𝐞 𝐏𝐚𝐭𝐭𝐞𝐫𝐧 𝐭𝐡𝐚𝐭 𝐋𝐞𝐝 𝐭𝐨 𝐭𝐡𝐞 𝟕,𝟒𝟓𝟐% 𝐑𝐚𝐥𝐥𝐲 𝐢𝐧 𝟐𝟎𝟏𝟕 👀🔥 A new side-by-side chart shows XRP’s 𝟐𝟎𝟐𝟓 𝐬𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞 𝐢𝐬 𝐚𝐥𝐦𝐨𝐬𝐭 𝐢𝐝𝐞𝐧𝐭𝐢𝐜𝐚𝐥 𝐭𝐨 𝟐𝟎𝟏𝟕 — same… pic.twitter.com/14uIZQxRus — Diana (@InvestWithD) December 7, 2025 De Ripple koers laat nu precies dat punt zien. De steun rond de zone van ongeveer twee dollar blijft tot nu toe sterk. De weerstand rond $ 2,20 blijft hard, maar dat was in 2017 niet anders. Diana herkent het patroon meteen. Niet omdat het perfect moet zijn, maar omdat de structuur gelijk is. Lees ook ons artikel over Solana dat XRP provoceert met ‘589’ en illustratie — wat zit hierachter? Wanneer gaat Ripple stijgen? Alles draait op dit moment om de zone boven $ 2,20. Zolang XRP daar niet doorheen sluit met kracht, blijft de Ripple koers vlak. In de grafiek zie je dat elke poging om boven deze weerstand te komen snel wordt teruggeduwd. Dat maakt de beweging traag en voorzichtig. Steun en weerstand + EMA’s XRP koers – bron: TradingView De RSI staat neutraal. Dat betekent dat er ruimte is voor een stevige beweging zodra de koers richting de weerstand loopt. In 2017 brak die beweging pas los na weken van dezelfde zijwaartse fase. Het is dus geen zwakte, maar een periode waarin kopers en verkopers elkaar in evenwicht houden. Bekijk hier de Ripple koersverwachting voor de lange termijn. Praat mee op onze socials! Chat met onze experts via Telegram, geef je mening op Twitter of "sit back and relax" terwijl je naar onze YouTube-video's kijkt. Chat met ons Geef je mening Bekijk onze video's Ripple kopen blijft vooral een patroon spel Veel handelaren die nu Ripple kopen doen dat vanwege het patroon. Ze kijken minder naar het nieuws en meer naar de vergelijking met 2017. De grafiek laat namelijk zien dat XRP in beide jaren rond hetzelfde punt draaide voordat de grote stijging begon. Toch blijft de markt bewust rustig. De fundamentals zijn sterker dan in 2017, maar de Ripple koers laat dat nog niet zien. Dat maakt het patroon interessant, maar niet automatisch explosief. Het is vooral een technische reden om XRP strak in de gaten te houden. Voor de liefhebbers hebben we een lijst samengesteld met crypto’s die gaan stijgen naast XRP. Wat gaat de Ripple koers doen als de weerstand eindelijk breekt? De weerstand van $ 2,20 is het niveau dat alles kan openzetten. Komt er volume achter, dan kan XRP snel richting $ 3,00 – $ 3,50 bewegen. Pas boven die zone ontstaat ruimte voor een grotere stijging, vergelijkbaar met de verticale fase uit 2017. Zakt de Ripple koers onder de steun rond $ 2,00, dan duurt het langer voordat het patroon opnieuw kracht krijgt. De structuur blijft dan staan, maar de uitbraak schuift verder vooruit. Voor nu staat XRP precies op het punt waar de rally van 2017 ook begon. De grafiek klopt, het sentiment is voorzichtig positief en de markt wacht op de eerste candle die laat zien welke kant het opgaat. Nieuwe altcoin met snelgroeiende community Als het patroon van 2017 zich herhaalt, kan een XRP rally een algehele bull run ontketenen. In het verleden hebben we gezien dat memecoins zoals Dogecoin hier het meeste van profiteren. Dat maakt het een interessant moment om te kijken naar het laatste lid van de Doge familie met een snelgroeiende community. Maxi Doge ($MAXI) is het “bro gym” neefje van Dogecoin en zit vol met Red Bull, testosteron, pre-workout en 1000x leverage. Het is voor degenen die de eerste rally’s van DOGE, WIF en SHIB gemist hebben. Vroege investeerders kunnen nu al hun $MAXI tokens staken tegen het hoge jaarlijkse rendement van 72%. Hier is al massaal gebruik van gemaakt, want er staan al meer dan 10 miljard $MAXI tokens vast in het stakingsysteem. Je hebt nog even de tijd om je eerste $MAXI tokens te bemachtigen voor de huidige lage prijs. Bij elke nieuwe fase van de presale hoort namelijk een nieuwe prijsverhoging. Nu naar Maxi Doge i Kennisgeving: Dit artikel bevat inzichten van onafhankelijke auteurs en valt buiten de redactionele verantwoordelijkheid van BitcoinMagazine.nl. De informatie is bedoeld ter educatie en reflectie. Dit is geen financieel advies. Doe zelf onderzoek voordat je financiële beslissingen neemt. Crypto is zeer volatiel er zitten kansen en risicos aan deze investering. Je kunt je inleg verliezen. Het bericht XRP triggert patroon dat voorafging aan eerdere 7000% stijging is geschreven door Christiaan Kopershoek en verscheen als eerst op Bitcoinmagazine.nl.
Share
Coinstats2025/12/11 03:16