# How Twitter Added Strong Authentication to its Hadoop Clusters Without Taking HDFS Down
*Twitter rolled out Kerberos across tens of Hadoop clusters and hundreds of thousands of apps without user code changes, with zero HDFS downtime.*
By [Rohit Lakhotia](https://scaleengineer.com/authors/rohit-lakhotia)
Published: 2026-11-23
Canonical: https://scaleengineer.com/blog/how-twitter-added-strong-authentication-to-its-hadoop-clusters-without-taking-hdfs-down
---
Imagine an office building where anyone who says "Hi, I'm Rahul from Finance" at the door is let in\. Nobody checks an ID card\. Once inside, rooms have locks, and every visit is written in a logbook\. But the whole system depends on people being honest about who they are\. For years, Twitter's Hadoop setup worked a lot like that\.

Twitter runs one of the largest [Hadoop](https://hadoop.apache.org/) installations in the world\. It powers search, AI/ML, metrics and reporting, spam and abuse prevention, ads, internal tools, and more\. The numbers are huge:

- Tens of Hadoop clusters
- Thousands of nodes
- Hundreds of petabytes of data, before replication
- Tens of thousands of MapReduce and Spark jobs every day

Some of that data is sensitive, and it's used by engineering, product, business, finance, and legal teams\. Twitter needed to know for certain who was accessing it\.

The fix is well known: [Kerberos](https://www.geeksforgeeks.org/computer-networks/kerberos/), a strong authentication system that Hadoop already supports\. The hard part was turning it on across tens of busy clusters without downtime and without asking thousands of teams to change their code\. Let's understand how Twitter did it in this blog today\.

## First, What is Hadoop?

Hadoop is a system for storing and processing massive amounts of data across many machines\. Two parts matter here\.

HDFS \(Hadoop Distributed File System\) stores the data:

- NameNode: the "librarian\." It keeps track of which files exist and where their pieces are stored\. Clients ask it first\.
- DataNodes: the "shelves\." They store the actual data blocks\.

YARN runs the jobs that process the data:

- ResourceManager: the "manager\." It accepts jobs and decides where they run\.
- NodeManagers: the "workers\." They run the job's tasks on each machine\.

A client is any app or service that talks to Hadoop, like a job, a script, or a microservice reading data\.

## The Three A's of Security

To protect data properly, you need three things:

1. Authentication: proving *who you are*\.
2. Authorization: deciding *what you're allowed to do*\.
3. Accountability: recording *what you did*\.

Twitter already had two of these:

- Authorization: HDFS uses Unix\-like permissions\. Every file and folder has an owner, a group, and access permissions\.
- Accountability: HDFS audit logs record every operation, like listing, opening, reading, or deleting a file, along with the user's name, IP address, the file accessed, and the action performed\.

The missing piece was authentication\. Hadoop's default mode, called "simple" authentication, trusts whatever username the client claims to be\. Permissions and logs are only as good as that claim\. If anyone can say "I'm the finance user," the permissions on finance data don't mean much\.

## What is Kerberos?

Kerberos is a way to prove who you are on a network without sending your password around\.

Think of it like a theme park:

1. You show your ID once at the main gate\. The gate is the KDC \(Key Distribution Center\), the trusted authority that knows everyone's identity\.
2. You get a day pass\. This is the TGT \(Ticket Granting Ticket\)\. It proves you've already been verified\.
3. For each ride, you show your day pass and get a ride ticket\. This is a service ticket, a pass for one specific service, like the NameNode\.
4. The ride operator checks your ticket, not your ID\. The service trusts the ticket because the KDC issued it\.

A few more terms:

- Principal: an identity in Kerberos, like `foo@COMPANY.COM` for a user or `namenode/host@COMPANY.COM` for a service\.
- Keytab: a file holding a principal's secret key\. Machines and services can't type passwords, so they use keytabs to log in automatically\.
- kinit: the act of logging in to the KDC and getting a TGT\.

Once a Hadoop cluster is "kerberized," every client must show a valid Kerberos ticket\. No ticket, no access\.

## The Building Blocks Twitter Needed

### 1\. A KDC That Could Handle Hadoop's Scale

Twitter already had a KDC because other systems used Kerberos\. But Hadoop would add a lot of load:

- Tens of thousands of new service principals for Hadoop services
- Thousands of client principals for service accounts
- Hundreds of extra queries per second for logins and service tickets

Twitter's KDC team handled this with some tuning on the main KDC and a few extra replicas\.

### 2\. A Way to Create and Deliver Keytabs

Every service and machine needs the right keytab in the right place\. Other teams at Twitter had the same need, so the platform security team built two services:

- A keytab generation service that teams use to request keytabs\.
- A secure distribution service that delivers keytabs to the right hosts\.

These APIs were flexible enough to build more tools on top, like per\-host keytabs and a self\-service web UI\.

### 3\. A Smart Choice for NameNode Identity

Twitter gave each host its own service principal, like `fooService/host1@COMPANY.COM`\. The reason is to reduce the blast radius: if one machine is hacked, only that machine's key is exposed, not every machine's\.

But they made one exception: the NameNodes\.

For reliability, Hadoop runs two NameNodes, an active one and a standby\. If the active one fails, the standby takes over\. This is called failover\.

Here's the problem\. If each NameNode had its own principal, a failover would force thousands of clients to request new service tickets for the new NameNode all at once, flooding the KDC\.

So Twitter gave both NameNodes the same principal\. After a failover, clients' existing tickets still work\.

## Why This Was So Hard

### Problem 1: Kerberos Is All or Nothing

Once a service is kerberized, it drops every client that doesn't have a valid ticket\. That means every client had to be ready before the switch: hundreds of teams and thousands of jobs\.

Twitter considered two shortcuts:

- "Fail open": let unauthenticated clients through anyway\.
- An allowlist: let specific users skip authentication\.

Both were rejected\. They defeat the purpose of strong authentication and only delay the real fix\. They also encourage bad habits, like switching to an allowlisted user to get around the check\. And neither is a built\-in Hadoop feature\.

### Problem 2: Thousands of Microservices Use Hadoop

Many Twitter microservices run thousands of instances, and many embed the Hadoop client library\. To talk to a kerberized cluster, each instance needed a keytab on its host and a restart so it could log in with it\.

Restarting a service with thousands of instances can take days\. Announcing "Hadoop gets kerberized on Monday, restart everything after" doesn't work when many services operate at that scale\.

### Problem 3: Clusters Depend on Each Other

There were tens of clusters, and they couldn't all be kerberized at once\. So for a while, some clusters would be kerberized and some wouldn't\. What happens when a job in an unprotected cluster needs data from a protected one? It fails\.

Twitter mapped out which clusters depended on which, hoping to find a safe order\. It didn't work\. There were many circular dependencies, where cluster A needs B and B needs A\.

Two things made it worse:

- Data replication jobs: copy jobs run in the destination cluster and read from the source cluster\. If the source is kerberized and the destination isn't, the copies fail\.
- ViewFS: Twitter uses ViewFS, which lets an app see multiple clusters as one big file system\. That makes cross\-cluster reads and writes easy, but it also made it very hard to know how many cross\-cluster dependencies existed\.

## Options Twitter Rejected

1\. Build new kerberized clusters and migrate everything\. A clean start means nothing breaks\. But it means a long migration and much higher hardware and operating costs\. Worse, cross\-cluster use cases would break between old and new clusters\.

2\. Route everything through a proxy\. Inspired by Hadoop's HttpFS, Twitter considered a proxy that authenticates clients and talks to Hadoop using each user's Kerberos credentials\. Clients wouldn't need Kerberos, but they'd still need to authenticate with the proxy, and cross\-cluster problems would remain\. The proxy would also hold every user's keytab, so a single compromised proxy would expose everyone\.

3\. Take downtime\. Downtime on one cluster might be fine\. But because of circular dependencies, they'd need downtime on several clusters at once\. That was too risky\.

## The Guiding Principles

Twitter set five rules for the project:

1. No user code changes\. Thousands of apps can't be asked to recompile and redeploy\.
2. Know who's ready and who isn't\. Chasing a handful of teams is far easier than chasing hundreds\.
3. Kerberize clients and workers first, the master services last\. Doing it the other way around causes huge downtime\.
4. Don't break cross\-cluster use cases\. Nobody wants to debug random failures on deployment day\.
5. Have a rollback plan\. Always\.

The key to rule 3 is a built\-in Hadoop setting:

```
ipc.client.fallback-to-simple-auth-allowed = true
```

In simple terms: a kerberized client with this setting can talk to *both* kerberized and non\-kerberized services\. If the service asks for a Kerberos ticket, it shows one\. If not, it falls back to the old simple mode\.

That changes everything\. Twitter could make every client Kerberos\-ready *ahead of time* without breaking anything, and flip the servers later\.

## Solution 1: Automatic Login From Keytab

Normally, a Hadoop app must explicitly log in using its keytab with a call like:

```
UserGroupInformation.loginUserFromKeytab(principal, keytabPath);
```

That's a code change, which Twitter wanted to avoid\.

But Twitter's services load the Hadoop client library and configuration at runtime\. So as long as a new library version stays API\-compatible, Twitter can deploy it to every host without breaking any app\.

Twitter changed the library so it logs in automatically\. When an app runs as Unix user `foo`, the library:

1. Checks whether `foo`'s keytab exists at a standard path, like `/standard/path/foo.keytab`\. This is where the distribution service drops keytabs\.
2. If there's no keytab: the app works as before\. It can talk to non\-kerberized clusters but not kerberized ones\.
3. If the keytab exists: the library logs in automatically and gets a TGT\. With the fallback setting on, the app can talk to *both* kerberized and non\-kerberized clusters\.

In simple terms: to make an app Kerberos\-ready, Twitter just had to put a keytab on its host\. No code changes, no special deploy\.

## Solution 2: Using Audit Logs to Find Who's Not Ready

HDFS audit logs record how each user authenticated\. Simplified, they look like this:

- Kerberized user: `ugi=foo@COMPANY.COM (auth:KERBEROS)`, so the user is ready\.
- Non\-kerberized user on an unprotected cluster: `ugi=foo (auth:SIMPLE) allowed=true`, so the user still works but isn't ready yet\.
- Non\-kerberized user on a protected cluster: `ugi=foo (auth:SIMPLE) allowed=false`, so the user is blocked\.

By searching the logs for `auth:SIMPLE`, Twitter could see exactly which apps weren't ready yet\.

Auto\-login, the fallback setting, and audit logs together made hundreds of thousands of client apps Kerberos\-ready\. The apps left over usually belonged to fewer than 10 teams, and Twitter contacted them directly\.

## Solution 3: Fixing Cross\-Cluster Jobs With Delegation Tokens

### What's a Delegation Token?

When you submit a big MapReduce job, it runs as hundreds or thousands of tasks across many machines\. If every task logged in to the KDC separately, the KDC would be flooded\.

So Hadoop uses delegation tokens\. Your app logs in once, asks the NameNode for a token, and hands it to the job\. Every task uses that token to access HDFS\.

In simple terms: it's like getting a signed permission slip at the front desk once, photocopying it, and giving a copy to each worker, instead of sending every worker to the front desk\.

The ResourceManager renews these tokens right after the job is submitted and again before they expire, up to a set maximum lifetime\.

### What Broke

With the fallback setting:

- A job in a kerberized cluster could read from a non\-kerberized cluster\. For example, a DistCp copy job could pull data from an unprotected cluster\.
- A job in a non\-kerberized cluster could not read from a kerberized cluster\.

Here's why the second case failed\. Say user `kerbFoo` submits a job to the unprotected cluster `nonKerbHadoop` that reads from the protected cluster `kerbHadoop`:

1. `kerbFoo` logs in to `kerbHadoop` successfully\.
2. `kerbFoo` talks to `nonKerbHadoop` in simple mode, using the fallback setting\.
3. `kerbFoo` gets a delegation token from `kerbHadoop`'s NameNode\.
4. `kerbFoo` passes that token to `nonKerbHadoop`'s ResourceManager\.
5. The token goes unused\. Hadoop only runs its token\-handling logic when security is turned on, and `nonKerbHadoop` isn't kerberized\. So the tasks never get a usable token for `kerbHadoop`\.

### The Fix

Twitter changed the delegation token flow so it also works when the cluster's own security is off\. A non\-kerberized ResourceManager now carries the token from the kerberized cluster through to the job\.

Does that weaken security? No\. These clusters had no strong authentication to begin with, and the data is still protected by HDFS ownership and permissions\.

## Solution 4: Stopping ViewFS From Asking Every Cluster for Tokens

When a job is submitted, Hadoop requests delegation tokens for the job's input and output folders\.

But at Twitter, paths go through ViewFS, which combines every accessible cluster into one big file system\. When Hadoop asked "which file system holds this path?", it got back the combined view of *all* clusters\.

As a result, every job submission requested delegation tokens from every single HDFS cluster, even ones the job never touched\.

Twitter fixed this by adding a new API:

```
getTargetFileSystem(Path p)
```

It returns the one actual cluster that holds a given path\. Jobs now request tokens only from the clusters their inputs and outputs actually live on\.

## The Rollout: One Cluster at a Time

With clients ready and the fallback setting enabled everywhere, Twitter kerberized one cluster at a time in this order:

1. Hadoop client apps: they're already ready, so nothing breaks\.
2. NodeManagers and DataNodes: the thousands of worker machines\.
3. ResourceManager, Job History Servers, and Shared Cache Manager: jobs already running fail at this point, because they were launched without Kerberos credentials\. They retry automatically and succeed\.
4. ZKFC: the process that monitors NameNode health and handles failover\.
5. NameNodes: the HDFS "librarians\."
6. JournalNodes: they store the NameNode's shared change log\.

The result was zero HDFS downtime and minimal YARN downtime\.

### The Rollback Plan

Rolling back runs in reverse order, but it doesn't need to go all the way\. Twitter only had to un\-kerberize the master services: JournalNodes, NameNodes, ZKFC, ResourceManager, Job History Servers, and Shared Cache Manager\.

That's fewer than 10 hosts per cluster, compared with thousands of worker machines\. So a rollback is fast\.

## How It Went

Twitter kerberized its clusters one at a time, in place, with little disruption\. Jobs retry automatically when they fail, so brief failures during the switch didn't hurt users\.

Audit logs showed in advance which apps were ready, which made tracking and conversations with teams simple\. After the first couple of clusters, the site reliability team documented the steps, making the process repeatable\.

The success rate was very high, and the number of unique failures after each deployment was extremely low\.

Compared with building parallel kerberized clusters, Twitter estimates the approach saved millions of dollars, plus many hours of operations, planning, and execution work\.

## The Bigger Picture

Kerberos wasn't the hard part\. Hadoop supports it out of the box\. The hard part was switching it on in a huge, busy system where nothing could go down and nobody could be asked to change their code\.

Twitter's answer was to separate getting ready from flipping the switch\. The fallback setting let every client become Kerberos\-ready months ahead without breaking anything\. Audit logs turned "who isn't ready?" into a simple query\. And because rollout and rollback were planned carefully, each cluster's switch\-over was a routine step rather than a risky one\-off event\.

It's a useful lesson for any large migration: make the new path work alongside the old one, measure who has moved, and switch only when almost everyone is already there\.

## Key Takeaways

- The goal: add strong authentication \(Kerberos\) to tens of Hadoop clusters holding hundreds of petabytes of data\.
- The constraints: Kerberos is all\-or\-nothing, thousands of microservices embed Hadoop clients, and clusters have circular dependencies on each other\.
- Rejected options: new parallel clusters \(expensive and breaks cross\-cluster jobs\), a central proxy \(huge blast radius\), and downtime \(too many clusters at once\)\.
- The key setting: `ipc.client.fallback-to-simple-auth-allowed=true` lets kerberized clients talk to both protected and unprotected clusters\.
- Auto\-login: the updated Hadoop client library logs in automatically if a keytab exists at a standard path, with no code changes needed\.
- Audit logs: `auth:SIMPLE` entries revealed which apps weren't ready, leaving fewer than 10 teams to contact\.
- Delegation token fix: jobs in non\-kerberized clusters can now read from kerberized ones\.
- ViewFS fix: `getTargetFileSystem()` stopped jobs from requesting tokens from every cluster\.
- Rollout order: clients first, then workers, then master services, giving zero HDFS downtime\.
- Fast rollback: only fewer than 10 master hosts per cluster need reverting\.
- Impact: millions of dollars saved compared with building parallel kerberized clusters\.

## Key Takeaways

- The goal: add strong authentication \(Kerberos\) to tens of Hadoop clusters holding hundreds of petabytes of data\.
- The constraints: Kerberos is all\-or\-nothing, thousands of microservices embed Hadoop clients, and clusters have circular dependencies on each other\.
- Rejected options: new parallel clusters \(expensive and breaks cross\-cluster jobs\), a central proxy \(huge blast radius\), and downtime \(too many clusters at once\)\.
- The key setting: `ipc.client.fallback-to-simple-auth-allowed=true` lets kerberized clients talk to both protected and unprotected clusters\.
- Auto\-login: the updated Hadoop client library logs in automatically if a keytab exists at a standard path, with no code changes needed\.
- Audit logs: `auth:SIMPLE` entries revealed which apps weren't ready, leaving fewer than 10 teams to contact\.
- Delegation token fix: jobs in non\-kerberized clusters can now read from kerberized ones\.
- ViewFS fix: `getTargetFileSystem()` stopped jobs from requesting tokens from every cluster\.
- Rollout order: clients first, then workers, then master services, giving zero HDFS downtime\.
- Fast rollback: only fewer than 10 master hosts per cluster need reverting\.
- Impact: millions of dollars saved compared with building parallel kerberized clusters\.

Official blog from Twitter: **[Kerberizing Hadoop Clusters at Twitter](https://blog.x.com/en/engineering/kerberizing-hadoop-clusters-at-twitter)**

By now, you must have had a clear idea of,** How Twitter Added Strong Authentication to Its Hadoop Clusters Without Taking HDFS Down**? In a nutshell, Twitter made every client Kerberos\-ready ahead of time using auto\-login and a fallback setting, used audit logs to track who wasn't ready, fixed cross\-cluster token handling, and kerberized clusters one at a time with zero HDFS downtime\.

**Congratulations\! You've just advanced another step in your tech journey\. Keep progressing\!**
