Introduction

If you have ever run multiple query engines (such as Spark and Trino) on the same data lake, you have probably encountered situations where those query engines do not see the same schemas in production. Apache Iceberg’s REST Catalog solves this metadata management problem by providing a centralized HTTP API for managing table metadata, ensuring that all engines have a consistent view of partitions, schemas, and snapshots.

This blog will help data engineers learn:

– How Iceberg manages metadata through its layered architecture

– The role of catalogs as the single source of truth 

– Why REST Catalog is preferred for multi-engine environments

– How to set up and test the REST Catalog locally using Docker


What is Iceberg?

To help you understand how Apache Iceberg organizes large amounts of data, I will first briefly explain to you what Apache Iceberg is and how it works.

Apache Iceberg is an open-source table format that provides ACID transactions, time travel, and schema evolution for data lakes. It provides a metadata management layer that enables data processing tools (such as Spark, Presto, Hive) to efficiently access data in storage (such as Hadoop or S3). Separating processing tools from storage creates flexibility, allowing any processing tool to access any storage.

Apache Iceberg Architecture Overview

Figure 1. Apache Iceberg Architecture OverviewFigure 1. Apache Iceberg Architecture Overview (source)

Figure 1 shows the architecture of the Apache Iceberg format, which consists of two layers:

  • Data layer – this layer contains the physical data, partitioned into multiple files. The data is usually stored in formats like Parquet, Avro, or ORC.

Metadata layer – this layer holds the metadata that describes the table and is divided into three types of files:

A snapshot captures the state of your table at a specific point in time. Every time you modify data through write commands such as INSERT, DELETE, UPDATE, and MERGE, a new metadata file is created. Schema-only changes may or may not result in the creation of a new metadata file. The metadata file contains a list of previous snapshots and creates a new one for the current state of the table. Each snapshot points to a manifest list file. These snapshots give you safety. If something goes wrong, you can always roll back to any previous state of your data.

Apache Iceberg Catalog

The third layer in Apache Iceberg’s architecture is the Iceberg Catalog. Simply put, the Iceberg Catalog is a concept that manages a pointer to the most recent version of the table’s metadata. It’s important to remember that catalogs don’t contain any actual data – they only maintain these references.

Types of Iceberg Catalogs

Based on how they store and access references to metadata, Iceberg catalogs can be divided into two types:

File-based catalogs:

These catalogs work directly with the file system. All metadata is stored right at the location, and the user or system accessing it must know the exact path to the metadata. These catalogs are easier to set up, but it’s harder to share them between teams. An example of a catalog using a file-based approach is Hadoop.

Service-based catalogs:

These catalogs rely on an external service (like Hive Metastore, REST API, Glue, Nessie, etc.) to centrally manage metadata. They are designed for scale and collaboration, and you only need to know a table name. The trade-off with these catalogs is that they are more challenging to configure initially. Examples of catalogs that use services are:

  • HiveCatalog
  • RESTCatalog
  • GlueCatalog
  • NessieCatalog

Picking the right service catalog:


If you are unsure which catalog fits your needs and you expect an evolving infrastructure, choose the REST Catalog. It is one of the most flexible catalog implementations in the Iceberg ecosystem. 

Iceberg REST Catalog Architecture Overview

Figure 2. Rest Catalog Flow Figure 2. Rest Catalog Flow

Figure 2 shows a diagram of a typical REST catalog architecture in the Iceberg ecosystem:

Client
The client is a tool that uses Apache Iceberg to manage tables. This can be any system; examples include Spark, Flink, Trino, Presto, and others.
The client sends REST requests to the REST catalog to retrieve table metadata.

REST Catalog
This is the first point of contact between the client and the Iceberg metadata. It is a client-side library that implements the Iceberg REST API specification and translates Iceberg API calls into HTTP requests. Those requests are then forwarded to the REST Server for processing.

REST Server
The REST server is a backend application that implements the entire business logic of the Iceberg REST API. It performs all metadata operations, such as viewing and retrieving metadata.

Database
The database stores metadata about tables (for example, PostgreSQL, MySQL, or another database). The REST server uses this database to store and read data about tables and snapshots. The advantage of the REST server is that it can use any other catalog in the background to process requests (for example, HiveCatalog). The client still accesses metadata through REST API calls.

Why You Should Use Iceberg REST Catalog 

REST Catalog gives one HTTP endpoint, which all tools use to communicate; they are all using the same API calls to get metadata. This solves some of the problems:

    • Consistency: There are no more situations where something works in Spark but not in Trino due to metadata mismatches.
    • Backend that is easy to swap: You can start with a simple backend solution and then migrate to a more complex one without touching client configuration. You were using PostgreSQL, but all of a sudden you have to migrate to something else? Do it without touching client configs.
    • Simple scaling: It is HTTP, so to scale it, all you need is a load balancer, run a few instances, and that’s it.
    • Centralised authentication: REST catalog simplifies security by introducing a single access control point. It supports OAuth2, API keys, and other modern authentication methods.
    • Observability: Log every metadata request, track who is accessing what

Why You Should Not Use Iceberg REST Catalog 

REST Catalog has some limitations as well that you should consider before implementing:

    • Maintenance and Complexity: You have introduced an additional backend service into your system that needs to be deployed, monitored, secured, and maintained.
    • Network dependency: If your REST server is not available, the whole system is unavailable.
    • Network overhead: Every HTTP request adds some latency. Complex queries with a lot of tables and partitions can add significant cumulative latency.
    • Scalability bottleneck: If you have not planned your infrastructure well, the REST Catalog can easily become a bottleneck.
    • Implementation limits: Some implementations can introduce their own limitations, such as a lack of multi-region or custom-region bucket support, or support only a single-level namespace.


Local Setup Walkthrough

To see the REST Catalog in action, we will set up a local environment using Docker.

What you need:

  • MinIO: An S3-compatible storage for keeping data.
  • Iceberg REST Catalog: A RESTful service that manages metadata and uses MinIO as the storage.
  • Apache Spark: For testing and interacting with the REST catalog through the spark-shell.

Full setup with code: https://github.com/ATLANTBH/rest-catalog-setup/

The repository includes the complete Docker and Spark configuration, detailed step-by-step instructions, and additional demo queries. Just clone it and run docker-compose up.

Demo queries 

Once Docker Compose is running and you have created a MinIO bucket, you are ready to run the Spark shell and start querying. Here are a few queries to try:

  1. Verifying the REST Catalog:
spark.sql("SELECT current_catalog()").show()

Expected output: irc

  1. Create a Test Table:
 spark.sql("CREATE NAMESPACE IF NOT EXISTS demo")

spark.sql(""" 
    CREATE TABLE IF NOT EXISTS demo.users (
       id INT,
       name STRING,
       email STRING,
       age INT,
       created_at TIMESTAMP
     )
     USING iceberg
     PARTITIONED BY (days(created_at))
   """)
  1. Insert data and query it:
spark.sql("""
    INSERT INTO demo.users VALUES
      (1, 'Alice Johnson', '[email protected]', 30, TIMESTAMP '2024-01-15 10:00:00'),
      (2, 'Bob Smith', '[email protected]', 25, TIMESTAMP '2024-01-16 11:30:00'),
      (3, 'Charlie Brown', '[email protected]', 35, TIMESTAMP '2024-01-17 09:15:00')
  """)

spark.sql("SELECT * FROM demo.users ORDER BY id").show()

You should be able to see the data inserted in the table. Also, if you check the MinIO dashboard, you will see your namespace, table, data, and all metadata files.


Production Considerations

While our Docker setup demonstrates the core architecture, production deployments require additional consideration:

  • Storage: Replace MinIO with production-grade object storage such as Azure Blob Storage or AWS S3.
  • High Availability: Deploy multiple REST Catalog instances behind a load balancer and configure some health check endpoints.
  • Security: Plan your security architecture across three layers: authentication, authorization, and network security (TLS encryption, private subnets, etc.).
  • Observability: Implement metrics visualisation (such as Prometheus + Grafana) and an alerting system.
  • Performance: Enable caching at multiple layers to reduce latency.


Conclusion

As we have seen through this blog, REST Catalog is a complex but powerful solution. If you are a small team or in a single-engine environment, the REST Catalog is not for you; it would introduce more problems than benefits.

However, for heterogeneous environments, the REST Catalog is one of the cleanest solutions available. As more tools are introduced into the system, this architecture becomes increasingly practical.


Leave a comment

Your email address will not be published. Required fields are marked *