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 service@support.mexc.com 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.
Share Insights

You May Also Like

Horror Thriller ‘Bring Her Back’ Gets HBO Max Premiere Date

Horror Thriller ‘Bring Her Back’ Gets HBO Max Premiere Date

The post Horror Thriller ‘Bring Her Back’ Gets HBO Max Premiere Date appeared on BitcoinEthereumNews.com. Jonah Wren Phillips in “Bring Her Back.” A24 Bring Her Back, a new A24 horror movie from the filmmakers of the smash hit Talk to Me, is coming soon to HBO Max. Bring Her Back opened in theaters on May 30 before debuting on digital streaming via premium video on demand on July 1. The official logline for Bring Her Back reads, “A brother and sister uncover a terrifying ritual at the secluded home of their new foster mother.” Forbes‘South Park’ Season 27 Updated Release Schedule: When Do New Episodes Come Out?By Tim Lammers Directed by twin brothers Danny Philippou and Michael Philippou, Bring Her Back stars Billy Barratt, Sora Wong, Jonah Wren Philips, Sally–Anne Upton, Stephen Philips, Mischa Heywood and Sally Hawkins. Warner Bros. Discovery announced on Wednesday that Bring Her Back will arrive on streaming on HBO Max on Friday, Oct. 3, and on HBO linear on Saturday, Oct. 4, at 8 p.m. ET. Prior to the debut of Bring Her Back on HBO on Oct. 4, the cable outlet will air the Philippou brothers’ 2022 horror hit Talk to Me. ForbesHit Horror Thriller ’28 Years Later’ Is New On Netflix This WeekBy Tim Lammers For viewers who don’t have HBO Max, the streaming platform offers three tiers: The ad-based tier costs $9.99 per month, while an ad-free tier is $16.99 per month. Additionally, an ad-free tier with 4K Ultra HD programming costs $20.99 per month. The Success Of ‘Talk To Me’ Weighed On The Minds Of Philippou Brothers While Making ‘Bring Her Back’ During the film’s theatrical run, Bring Her Back earned $19.3 million domestically and nearly $19.8 million internationally for a worldwide box office tally of $39.1 million. Bring Her Back had a production budget of $17 million before prints and advertising, according to The Numbers.…
Share
BitcoinEthereumNews2025/09/18 09:23
Talos Appoints Former Cowen Digital Head Drew Forman as SVP, Head of Strategy Amid Surge in Institutional Adoption of Digital Assets

Talos Appoints Former Cowen Digital Head Drew Forman as SVP, Head of Strategy Amid Surge in Institutional Adoption of Digital Assets

BitcoinWorld Talos Appoints Former Cowen Digital Head Drew Forman as SVP, Head of Strategy Amid Surge in Institutional Adoption of Digital Assets Leadership team expansion coincides with recent onboarding of large asset managers representing $21 trillion in AUM NEW YORK, Oct. 30, 2025 /PRNewswire/ — Talos, the premier provider of institutional digital assets technology and data for trading and portfolio management, announced the appointment of Drew Forman as Senior Vice President and Head of Strategy. In this newly created executive role, Forman will lead firmwide initiatives spanning market expansion, product innovation and corporate development as Talos continues to strengthen its position at the center of the institutional digital assets ecosystem. As Head of Cowen Digital, Forman launched a full-service, institutional digital assets platform that offered trade execution, custody through partners, and aggregated liquidity solutions for traditional institutions entering the market. He brings to Talos deep experience in derivatives trading, having led Cowen’s equity derivatives desk, co-led the trading desk at Macro Risk Advisors, and held senior derivatives trading roles at Nomura and J.P. Morgan. Most recently, at Hudson Bay Capital, he focused on the portfolio management and trading of equity volatility strategies, further demonstrating his analytical rigor in traditional finance. “We’re very fortunate to welcome Drew Forman to Talos,” said Anton Katz, CEO and Co-Founder of Talos. “We’ve seen significant growth in traditional institutions entering digital assets, and with that comes a tremendous opportunity for Talos to support their sophisticated workflows. Drew’s proven leadership in building and scaling businesses across traditional and digital finance makes him uniquely positioned to help chart Talos’s next phase of growth.” Forman will report directly to CEO Anton Katz, overseeing business strategy, exploring inorganic growth and partnership opportunities, and helping to define the firm’s long-term positioning across both digital and traditional asset markets. His mandate includes driving alignment across the organization and ensuring that Talos’s platform continues to be the trusted infrastructure layer for financial institutions. Forman’s appointment reflects Talos’s ongoing momentum and the broader wave of institutional engagement in digital assets. Over the past year, Talos has onboarded as clients multiple leading asset managers representing approximately $21 trillion in assets under management (AUM), as well as hedge funds collectively managing over $100 billion in AUM. In addition, several retail brokers have adopted Talos’s technology, enabling over 100 million end users to trade digital assets. Recent growth milestones also include the integration of the Talos order and execution management system (OEMS) with BlackRock’s Aladdin® investment platform, and the acquisitions of four best-in-class digital assets firms: data provider Coin Metrics, risk management platform Cloudwall, institutional DeFi technology provider Skolem, and portfolio engineering platform D3X Systems. These strategic moves advance Talos’s commitment to delivering an institutional-grade platform that supports the full lifecycle of digital asset investment. “I’ve followed Talos’s evolution with admiration, from assembling the broadest connectivity network to building out the most comprehensive execution and portfolio management system for digital assets,” added Forman. “This is an inflection point not only for Talos, but for the convergence of digital and traditional finance. I’m honored to join the leadership team to help shape the firm’s strategic direction and accelerate the next phase of growth.” About Talos Talos provides institutional-grade technology and data that supports the full digital asset investment lifecycle, including liquidity sourcing, price discovery, trading, settlement and portfolio management. Engineered by a team with unmatched experience building institutional trading, portfolio and data systems, the Talos platform connects institutions to key providers in the digital asset ecosystem – exchanges, OTC desks, prime brokers, lenders, custodians, and more – through a single interface. For additional information, visit www.talos.com. Talos Disclaimer: Talos offers software-as-a-service products that provide connectivity tools for institutional clients. Talos does not provide clients with any pre-negotiated arrangements with liquidity providers or other parties. Clients are required to independently negotiate arrangements with liquidity providers and other parties bilaterally. Talos is not party to any of these arrangements. Services and venues may not be available in all jurisdictions. MEDIA CONTACT: media@talos.com   This post Talos Appoints Former Cowen Digital Head Drew Forman as SVP, Head of Strategy Amid Surge in Institutional Adoption of Digital Assets first appeared on BitcoinWorld.
Share
Coinstats2025/10/30 20:45