Moderate Auth Question 111 of 226

JWT versus server session: how do you choose for a Spring Boot monolith that will scale out?

Java Specialist · Speak this in 60–90 seconds · Faridabad & Delhi NCR

PICTURE THIS: A SENTENCE BECOMES TOKENS

The model does not read letters like humans. It reads these pieces, then predicts the next one.

Simple meaning

Sessions need a shared store such as Redis once you have more than one app instance, or sticky load balancing which you should avoid.

1

WHY — Auth instead of guessing?

Why interviewers care about Auth:

They want a clean

contrast on Auth, not two memorised paragraphs.

Say what changes for

the developer, then one case where picking wrong hurts.

Stay structured

Name the idea, why it exists, then one short example.

Close cleanly

End with when you use it and one common pitfall.

2

STEPS — What happens with tokens?

Before the model can read a sentence, it goes through these steps:

  1. 1
    Sessions need a shared

    store such as Redis once you have more than one app instance, or sticky load balancing which you should avoid.

  2. 2
    JWTs move state to

    the client so any instance can verify the signature.

  3. 3
    JWTs are harder to

    revoke instantly

  4. 4
    Context mix

    sessions are easy to delete.

  5. 5
    Many teams use short-lived

    JWTs plus a refresh token in a Redis allow-list.

  6. 6
    Decode

    IDs turn back into readable text.

3

EXAMPLE — See it in action

Let's see how a real sentence is tokenized (tokens may vary by model):

Input text
“JWTs are harder to revoke instantly”
Tokenized output
JWTsarehardertorevokeinstantly
Token IDs (example)
2987408337471632900

Note: Actual tokens and IDs depend on the tokenizer (e.g., GPT, Llama, etc.).

Key takeaway

Sessions need a shared store such as Redis once you have more than one app instance, or sticky load balancing which you should avoid. JWTs move state to the client so any instance can verify the signature.

Chat with us