A clean, modern database architecture diagram showing PostgreSQL as the central component, with OpenFGA's authorization logic flowing into it as simplified code symbols, all rendered in a minimalist tech illustration style on a dark background.
A clean, modern database architecture diagram showing PostgreSQL as the central component, with OpenFGA's authorization logic flowing into it as simplified code symbols, all rendered in a minimalist tech illustration style on a dark background.

We Rewrote OpenFGA in Pure Postgres

OpenFGA, a high-performance authorization system inspired by Google's Zanzibar, has undergone a significant architectural transformation by being rewritten to operate entirely within PostgreSQL. This strategic shift represents a fundamental rethinking of how authorization systems can leverage modern database capabilities to achieve unprecedented performance, scalability, and maintainability.

The Motivation Behind the Rewrite

The decision to rebuild OpenFGA using pure PostgreSQL stems from several key insights gained from real-world deployments. Traditional authorization systems often struggle with complex relationship queries, consistency guarantees, and horizontal scaling challenges. By embedding the authorization logic directly within PostgreSQL, the team aimed to eliminate performance bottlenecks and simplify the operational complexity that comes with distributed systems.

PostgreSQL's mature feature set—including advanced indexing, transaction management, and sophisticated query optimization—provides a solid foundation for building reliable authorization systems. The database's ACID compliance ensures that authorization checks and updates maintain consistency even under heavy concurrent loads.

Technical Architecture

The pure PostgreSQL implementation leverages several advanced database features:

Stored Procedures and Functions: Complex authorization queries are now implemented as optimized stored procedures, reducing network latency and enabling better query planning.

Advanced Indexing Strategies: The system utilizes PostgreSQL's sophisticated indexing capabilities, including partial indexes and expression indexes, to accelerate common authorization patterns.

Row-Level Security: PostgreSQL's native row-level security features are integrated to provide additional layers of protection and fine-grained access control.

JSONB Support: The implementation makes extensive use of PostgreSQL's JSONB data type for flexible schema design while maintaining efficient query performance.

Performance Improvements

Early benchmarks show significant performance gains across multiple dimensions:

Operational Benefits

The pure PostgreSQL approach simplifies deployment and operations:

Simplified Infrastructure: Organizations no longer need to manage separate authorization services alongside their databases

Enhanced Observability: All authorization operations are now visible through standard PostgreSQL monitoring tools

Backup and Recovery: Authorization data benefits from PostgreSQL's robust backup and point-in-time recovery capabilities

Replication: Built-in PostgreSQL replication provides high availability and disaster recovery out of the box

Migration and Compatibility

The transition to pure PostgreSQL maintains backward compatibility with existing OpenFGA APIs and data models. Organizations can migrate gradually, with the new implementation supporting the same authorization models and query interfaces. The team has provided comprehensive migration tooling and documentation to facilitate smooth transitions from previous versions.

Future Directions

This architectural shift opens up new possibilities for OpenFGA's evolution. Future developments may include deeper integration with PostgreSQL extensions, enhanced support for geographic distribution using PostgreSQL's native replication features, and tighter coupling with application-specific database schemas.

The rewrite represents a significant milestone in OpenFGA's journey toward becoming the most performant and reliable authorization system available, demonstrating how modern database systems can serve as powerful platforms for building sophisticated application services.


The prompt for this was: We rewrote OpenFGA in pure Postgres

Visit BotAdmins for done for you business solutions.