Stateless services requests के बीच client state संग्रहीत नहीं करते (प्रत्येक request स्वतंत्र होती है), जबकि stateful services state बनाए रखते हैं। scalability के लिए statelessness महत्वपूर्ण है — stateless services को horizontally scale करना बहुत आसान होता है।
Stateless बनाम stateful
STATELESS → the service keeps NO client state between requests:
→ each request contains all needed info; any server can handle any request
→ state lives ELSEWHERE (database, cache, client, token) if needed
STATEFUL → the service MAINTAINS state across requests:
→ a specific server holds a client's state (session in memory, etc.)
→ requests must go to the SAME server (or state must be shared/synchronized)
