Translate

YARN In Hindi
Photo By : Christina Morillo

Updated on: 30 जुलाई 2025

Lesson 1: YARN का परिचय (Introduction to YARN In Hindi)

YARN का पूरा नाम है Yet Another Resource Negotiator, और यह Apache Hadoop framework का एक प्रमुख हिस्सा है। YARN को Hadoop 2.0 में introduce किया गया था ताकि distributed applications को बेहतर resource management और job scheduling मिल सके।

पहले Hadoop का Job Tracker और Task Tracker model rigid और limited था। YARN ने इसे बदलकर Hadoop को ज्यादा flexible और scalable बना दिया है। आज के समय में Hadoop YARN का उपयोग सिर्फ MapReduce jobs के लिए ही नहीं, बल्कि अन्य frameworks जैसे Apache Spark, Apache Flink, और Tez के साथ भी किया जाता है।

मुख्य उद्देश्य: YARN Hadoop cluster में चलने वाले सभी applications के लिए resources को efficiently allocate करता है, जैसे – memory, CPU आदि।

YARN को Hadoop का Operating System भी कहा जाता है, क्योंकि यह हर application के लिए resource decide करता है और job execution को manage करता है।

  • 📌 Introduced in Hadoop 2.0
  • 📌 Resource Management + Job Scheduling
  • 📌 MapReduce के limitations को दूर करता है
  • 📌 Apache Spark, Flink, Tez जैसी technologies को support करता है

Example: मान लीजिए आपके पास 10-node Hadoop cluster है। YARN यह तय करता है कि किस job को कितनी memory और कितने cores दिए जाएं, और किस order में execute हो।

Lesson 2: YARN के मुख्य Components क्या हैं?

YARN architecture में चार मुख्य components होते हैं जो मिलकर पूरे system को control करते हैं। ये components हैं:

  1. Resource Manager (RM): यह पूरे cluster का master होता है। इसका काम है सभी applications के लिए resource allocate करना और high-level job scheduling करना।
  2. Node Manager (NM): यह हर data node पर चलता है और local resources (memory, CPU) का record रखता है। ResourceManager को report करता है।
  3. ApplicationMaster (AM): हर application के साथ एक ApplicationMaster होता है, जो उस specific application के लिए job execution को manage करता है।
  4. Container: YARN में resources (CPU + memory) को Containers में divide किया जाता है। एक container एक task को चलाता है।

आसान भाषा में: ResourceManager एक नेता है, NodeManager उसका सहायक है, ApplicationMaster एक project manager है, और container काम करने वाला worker है।

Illustration:
एक Spark application के लिए YARN पहले ResourceManager से request करता है। फिर ResourceManager, NodeManagers के बीच resources allocate करता है। हर task को एक container मिलता है, जिसे ApplicationMaster handle करता है।

Lesson 3: YARN का Architecture – अंदर से कैसा दिखता है?

YARN का architecture यानी उसका ढांचा, Hadoop के resource management को modular और scalable बनाता है। YARN के architecture को समझना इसलिए ज़रूरी है क्योंकि इससे आपको पता चलता है कि Hadoop कैसे efficiently काम करता है – चाहे 10 machines हों या 10,000.

3.1 मुख्य Components

YARN architecture चार मुख्य components पर टिका होता है:

  • ResourceManager (RM): Cluster का दिमाग – कौन सा task कहाँ चलेगा, यही decide करता है।
  • NodeManager (NM): हर मशीन पर चलता है और उस मशीन के resources की जानकारी RM को देता है।
  • ApplicationMaster (AM): हर job का अपना mini-controller होता है – यह decide करता है कि उस job के अलग-अलग हिस्से कहाँ चलेंगे।
  • Container: YARN का execution unit – यानी जो task चलता है, वह Container में चलता है।

3.2 YARN में Component Interaction

एक typical YARN job कुछ इस तरह execute होता है:

  1. User कोई job submit करता है।
  2. ResourceManager उस job के लिए एक ApplicationMaster को container में start करता है।
  3. ApplicationMaster, ResourceManager से बात करता है और बाकी containers की मांग करता है।
  4. जब ResourceManager container allocate कर देता है, तो ApplicationMaster NodeManager से direct बात कर उन्हें activate कर देता है।

3.3 Scalability और Flexibility

YARN का modular architecture इसे बहुत scalable बनाता है:

  • Multiple frameworks (जैसे Spark, Tez, Flink) को support करता है।
  • Different scheduling algorithms को integrate किया जा सकता है (Fair Scheduler, Capacity Scheduler)।
  • Fault tolerance को बेहतर तरीके से manage करता है।

Lesson 4: ResourceManager क्या है – YARN का दिमाग

ResourceManager (या RM) YARN का सबसे critical component है – यह पूरे cluster के लिए centralized authority की तरह काम करता है।

4.1 दो मुख्य भूमिकाएं – Scheduler और ApplicationManager

  • Scheduler: Cluster में जितने भी resources हैं (CPU, RAM), उन्हें manage करता है। Scheduling policy (जैसे FIFO, Capacity या Fair) के हिसाब से tasks को containers allocate करता है।
  • ApplicationManager: हर नए application को manage करता है, उसके लिए ApplicationMaster launch करता है और उसकी life-cycle को monitor करता है।

4.2 ResourceManager कैसे काम करता है?

  1. User job submit करता है।
  2. ApplicationManager job को accept करता है और एक ApplicationMaster launch करने का निर्देश देता है।
  3. Scheduler resource availability देख कर container allocate करता है।
  4. ResourceManager ApplicationMaster को track करता है जब तक job पूरा न हो जाए।

4.3 ResourceManager के फायदे

  • Centralized control: पूरे क्लस्टर को एक ही जगह से manage करता है।
  • Pluggable Scheduling: अलग-अलग types के scheduler को support करता है।
  • Scalability: हज़ारों nodes तक क्लस्टर को आसानी से scale किया जा सकता है।

Lesson 5: NodeManager – YARN का सिपाही

NodeManager (NM) हर single machine (Node) पर चलता है और YARN के लिए local-level पर resource management का काम करता है। अगर ResourceManager दिमाग है, तो NodeManager हर machine पर उसका सिपाही है जो instructions को execute करता है।

5.1 NodeManager की जिम्मेदारियाँ

  • Container Management: ApplicationMaster के निर्देश पर containers को launch और monitor करता है।
  • Resource Reporting: हर कुछ समय पर ResourceManager को बताता है कि इस node पर कितना CPU, Memory available है।
  • Log और Status Tracking: चल रहे containers की स्थिति, logs और output को track करता है।

5.2 कैसे काम करता है NodeManager?

  1. ResourceManager से heartbeat signal प्राप्त करता है – ताकि centralized coordination बना रहे।
  2. जब ResourceManager container allocate करता है, तब NodeManager उसे launch करता है।
  3. ApplicationMaster के साथ direct communication करता है – ताकि task ठीक से execute हो सके।
  4. Execution के बाद logs को store करता है और ResourceManager को success/failure की रिपोर्ट करता है।

5.3 NodeManager के फायदे

  • Distributed Execution: हर node अपने आप काम करता है – जिससे Hadoop ज्यादा fast और fault-tolerant बनता है।
  • Resource Isolation: अलग-अलग containers को अलग resources में run करता है – ताकि performance बेहतर हो।
  • Scalability: Cluster में जितने भी nodes होंगे, उतने ही NodeManager होंगे – जिससे YARN आसानी से scale कर सकता है।

Lesson 6: YARN Container – Execution का असली मैदान

YARN का Container वह जगह होती है जहाँ पर असल में आपके task या process execute होते हैं। जब कोई ApplicationMaster किसी resource की demand करता है, तो ResourceManager उस request को पूरा करने के लिए एक NodeManager को निर्देश देता है कि वह container allocate करे।

6.1 Container क्या होता है?

Container, YARN का lightweight और isolated execution environment होता है। इसमें application-specific processes run होते हैं जैसे कि Map task, Reduce task या कोई custom code।

  • एक container में RAM, CPU cores और कभी-कभी Disk quota define होता है।
  • हर container एक unique ID और lifetime के साथ आता है।

6.2 Container कैसे allocate होता है?

  1. ApplicationMaster ResourceManager से resource की request करता है।
  2. ResourceManager NodeManager को instruct करता है कि वह उस resource के अनुसार एक container launch करे।
  3. NodeManager container को start करता है और application का code उस container में run होता है।

6.3 Container और Process Isolation

हर container एक isolated environment होता है, यानी:

  • एक container का crash होने से दूसरे container पर असर नहीं पड़ता।
  • Resource sharing controlled होता है – जिससे starvation या hogging नहीं होती।
  • Security भी मजबूत रहती है – एक container दूसरे के data को access नहीं कर सकता।

6.4 Real-world उदाहरण

मान लीजिए आप एक Spark job चला रहे हैं जिसमें 3 executors हैं। YARN हर executor को एक separate container में launch करेगा – ताकि वे isolated और parallel तरीके से run हो सकें।

6.5 Container की Limitation

  • अगर ResourceManager ठीक से quota allocate नहीं करता, तो container underutilized हो सकता है।
  • Container preemption या killing के cases में application unstable हो सकता है।
सीखते चलें: आपने जाना कि YARN Container कैसे execution का core हिस्सा होता है। अब आइए समझते हैं कि कौन decide करता है कि कौन सा काम कब और कहाँ चलेगा – यानी Scheduler की पूरी कहानी।

Lesson 7: YARN Scheduler – Resource Allocation का मास्टरमाइंड

YARN का Scheduler वो component है जो decide करता है कि कौन से job को कब और कितना resource मिलेगा। यह एक प्लानर की तरह काम करता है – जो fairness, priority, और capacity को ध्यान में रखकर resource distribute करता है।

7.1 Scheduler का मुख्य कार्य

  • Cluster में available resources को efficiently allocate करना
  • Multiple applications को manage करना
  • Fair access और Quality of Service सुनिश्चित करना

7.2 YARN में मुख्य Scheduler Types

  1. FIFO Scheduler – सबसे पहले आए, पहले पाए
  2. Capacity Scheduler – हर queue को एक fixed capacity मिलती है
  3. Fair Scheduler – सभी jobs को fairly resource allocate करता है

7.3 Scheduler कैसे काम करता है?

जब कोई job submit होती है, तो ApplicationMaster resource की मांग करता है। Scheduler उस demand को analyze करता है और available NodeManager को match करके Container allocate करता है।

7.4 Fair Scheduler vs Capacity Scheduler

Feature Fair Scheduler Capacity Scheduler
Resource Distribution Equal share among jobs Fixed quota per queue
Priority Support Moderate High
Ideal Use Case Multi-tenant environment Department-based allocation

7.5 Real-world Example

मान लीजिए एक cluster में दो departments हैं – Finance और Marketing। Capacity Scheduler के जरिए Finance को 60% और Marketing को 40% resource reserve किया जा सकता है। इससे business-critical jobs की priority बनी रहती है।

7.6 Key Takeaway

Scheduler YARN का दिमाग है – जो resource chaos को balance बनाता है। Job efficiency और cluster utilization में इसका role critical होता है।

Lesson 8: YARN ResourceManager – Cluster का King

YARN का ResourceManager पूरे cluster का master होता है। इसका काम है resource allocation को manage करना, applications की life-cycle को coordinate करना और overall system health को monitor करना।

8.1 ResourceManager के दो प्रमुख भाग

  • Scheduler: यह सिर्फ resources allocate करता है, execution पर कोई control नहीं रखता।
  • Application Manager: यह application को track करता है और ApplicationMaster launch करवाता है।

8.2 ResourceManager का Workflow

  1. User कोई application submit करता है
  2. Application Manager उस request को receive करता है
  3. Scheduler resource availability check करता है
  4. ApplicationMaster launch होता है
  5. ApplicationMaster Container की demand करता है
  6. Scheduler Containers allocate करता है

8.3 ResourceManager की Responsibilities

  • Cluster resources की accounting और tracking
  • NodeManagers से regular heartbeat लेना
  • Failed jobs को reschedule करना
  • Security और user access control maintain करना

8.4 ResourceManager vs JobTracker (Hadoop v1)

Feature ResourceManager (YARN) JobTracker (v1)
Architecture Modular (AM + Scheduler) Monolithic
Scalability High Limited
Failure Handling Better recovery via AM Single point of failure

8.5 Real-World Example

अगर आप Flipkart जैसे e-commerce platform पर job run कर रहे हैं, तो ResourceManager यह decide करता है कि कौन सा task कौन से node पर चलेगा, कितने cores और memory assign की जाएगी – ताकि पूरा workflow तेज़ और smooth चले।

8.6 Bonus Insight: High Availability

Production systems में दो ResourceManagers use किए जाते हैं – एक Active और एक Standby – ताकि failure की स्थिति में system crash न हो। इसे High Availability कहा जाता है।

8.7 Summary

ResourceManager YARN का दिल और दिमाग दोनों है। इसके बिना कोई भी job start ही नहीं हो सकती। यह ही scheduler और applications के बीच का bridge है जो पूरे cluster को smartly orchestrate करता है।

Lesson 9: NodeManager – YARN का Execution Agent

NodeManager (NM) हर slave machine (DataNode) पर चलता है और उस specific node के resources को manage करता है। YARN architecture में यह execution का primary agent होता है।

9.1 NodeManager का मुख्य कार्य

  • Containers की launching और monitoring
  • Resource usage (CPU, Memory) की रिपोर्टिंग
  • ApplicationMaster से communication
  • Log aggregation
  • Security और isolation सुनिश्चित करना

9.2 NodeManager vs TaskTracker (Hadoop v1)

Parameter NodeManager (YARN) TaskTracker (v1)
Execution Model Container-based Map/Reduce specific slots
Support for other frameworks Yes (e.g. Spark, Tez) No
Resource Flexibility Dynamic (CPU + RAM) Static slots

9.3 NodeManager का Life Cycle

  1. NodeManager स्टार्ट होते ही ResourceManager को heartbeat भेजता है
  2. जब ApplicationMaster किसी node पर container allocate करता है, वह NM को notify करता है
  3. NM container को launch करता है और उस पर running job को monitor करता है
  4. Completion के बाद logs collect करता है और result return करता है

9.4 Container क्या है?

Container एक isolated execution environment होता है जिसमें एक task run करता है। इसमें CPU, RAM और disk space assign की जाती है। NM का काम container launch करना और monitor करना होता है।

9.5 Real-World Example

मान लीजिए आप Ola की Big Data pipeline चला रहे हैं, तो हर incoming ride की event-processing job NodeManagers पर अलग-अलग containers में run होती है। इससे scalability और fault tolerance मिलती है।

9.6 Bonus Insight: Node Labels

YARN में आप nodes को label कर सकते हैं (जैसे – GPU, High-Memory, SSD)। इससे आप specify कर सकते हैं कि कौन सा application कौन से node पर चले।

9.7 Security और Isolation

  • NM container को Linux Cgroups और Docker जैसे technologies से isolate करता है
  • Each container को अलग-अलग users के permission में run किया जा सकता है

9.8 Summary

NodeManager एक intelligent agent की तरह काम करता है जो हर task को proper resource देकर उसे execute करता है और master (ResourceManager) को feedback देता है। यह modern Hadoop system की reliability की रीढ़ की हड्डी है।

Lesson 10: ApplicationMaster – Smart Manager of Each Job

ApplicationMaster (AM) YARN architecture का वह हिस्सा है जो किसी एक specific application/job को manage करता है। हर application के लिए एक अलग ApplicationMaster बनाया जाता है जो उस job की planning, coordination, और execution को संभालता है।

10.1 ApplicationMaster का मुख्य कार्य

  • ResourceManager से resource की demand करना (container allocation)
  • NodeManager से container launch करवाना
  • Tasks को monitor करना और failures को handle करना
  • Job की progress और status report करना
  • Job completion के बाद clean-up और logs submit करना

10.2 ApplicationMaster का Lifecycle

  1. Client ResourceManager से request करता है कि कोई application run करनी है
  2. ResourceManager एक container allocate करता है जिसमें ApplicationMaster को launch किया जाता है
  3. ApplicationMaster बाकी resources की request करता है और NM को tasks देता है
  4. Job की completion के बाद AM खुद को shut down कर लेता है

10.3 ApplicationMaster vs JobTracker

Feature ApplicationMaster (YARN) JobTracker (v1)
Architecture Per application AM Single JobTracker
Scalability High (No bottleneck) Low (Central bottleneck)
Failure Handling Independent retries per app Single point of failure

10.4 ApplicationMaster Framework Independence

ApplicationMaster सिर्फ MapReduce तक सीमित नहीं है। Spark, Tez, Hive, आदि frameworks अपने-अपने AM के साथ काम कर सकते हैं।

10.5 Real-World Use Case

मान लीजिए Flipkart का एक बड़ा ETL job है जो daily customer logs को clean और transform करता है। इस job के लिए एक ApplicationMaster बनाया जाता है, जो resource allocate करता है, task assign करता है और ensure करता है कि पूरी processing time पर complete हो जाए।

10.6 Fault Tolerance और Recovery

  • AM failure होने पर ResourceManager उसे दोबारा start कर सकता है
  • Intermediate job state save किया जा सकता है (checkpointing)

10.7 Monitoring Tools

आप YARN ResourceManager Web UI का उपयोग करके किसी भी running या completed AM का status, logs, और container details देख सकते हैं।

10.8 Summary

ApplicationMaster YARN की सबसे smart entity है जो एक job के लिए resource allocation से लेकर execution और monitoring तक सभी critical tasks संभालता है। इसकी वजह से YARN truly scalable और flexible बनता है।

Lesson 11: YARN Containers – Execution Unit of Tasks

YARN Container एक logical unit है जहां application का actual task execute होता है। हर container में एक specific amount of memory और CPU होता है जिसे ResourceManager द्वारा allocate किया जाता है और NodeManager द्वारा launch और manage किया जाता है।

11.1 Container क्या है?

Container एक isolated execution environment है जो:

  • Memory, CPU और अन्य system resources के साथ आता है
  • ApplicationMaster द्वारा assign किया गया task execute करता है
  • NodeManager के माध्यम से control होता है

11.2 Container कैसे Allocate होता है?

  1. ApplicationMaster ResourceManager से resource की request करता है
  2. ResourceManager availability के अनुसार resource assign करता है
  3. NodeManager उस resource के आधार पर container launch करता है

11.3 Container Execution Flow

  1. ApplicationMaster task को एक specific container में चलाने का निर्णय लेता है
  2. NM उस container को initialize करता है
  3. Task execution शुरू होता है
  4. Execution के बाद container terminate हो जाता है

11.4 Resource Isolation कैसे होता है?

YARN containers Linux cgroups या Docker जैसे technologies का उपयोग करके resource isolation सुनिश्चित करते हैं, ताकि एक container का overload दूसरे container को प्रभावित न करे।

11.5 Container Specification

Parameter Description
Memory Container को दी गई RAM (जैसे 2048 MB)
vCores CPU cores allocated
Priority Execution order preference
Execution Command Task को चलाने के लिए shell command

11.6 Real-Life Use Case

मान लीजिए Amazon का एक डेटा प्रोसेसिंग application है जिसमें कई टुकड़ों में डेटा analyze होता है। हर टुकड़ा अलग-अलग containers में process होता है। इससे parallel execution और better performance मिलती है।

11.7 Monitoring YARN Containers

ResourceManager और NodeManager web UI के माध्यम से आप देख सकते हैं:

  • कौन सा container किस node पर चल रहा है
  • Memory और CPU usage
  • Log files (stdout, stderr)

11.8 Container Failures

  • Hardware failure, memory overflow या task crash से container fail हो सकता है
  • ApplicationMaster ऐसे tasks को दोबारा किसी दूसरे container में चला सकता है

11.9 Summary

YARN Container किसी भी application का सबसे critical execution unit है जो resource isolated environment में task को efficiently run करता है। यह Hadoop को true distributed power देता है।

Lesson 12: NodeManager – Local Node का Boss

NodeManager (NM) YARN architecture का एक महत्वपूर्ण हिस्सा है, जो हर data node पर चलता है और उस local मशीन के containers और resources को manage करता है। यह ResourceManager के साथ मिलकर काम करता है लेकिन हर node का local control इसके पास होता है।

12.1 NodeManager का रोल

  • Local node के containers को launch और manage करना
  • Running containers की status रिपोर्ट भेजना ResourceManager को
  • Resource utilization (memory, CPU) monitor करना
  • Container logs और diagnostics maintain करना

12.2 NodeManager और ResourceManager का संबंध

NM, RM का subordinate है लेकिन अपने node के execution के लिए autonomous होता है। वह:

  1. Heartbeat भेजता है RM को हर कुछ सेकंड में
  2. Container statuses और health updates देता है
  3. Failure की स्थिति में retry या log reporting करता है

12.3 Container Launch Process by NM

  1. ApplicationMaster की request पर RM container allocate करता है
  2. RM उस container को launch करने का आदेश NM को देता है
  3. NM Linux process isolate करके container को launch करता है
  4. Task complete होने पर container terminate कर देता है

12.4 NodeManager Health Monitoring

  • Disk full, hardware issues या network failure को detect करता है
  • यदि node unhealthy होता है, तो वह RM को notify करता है
  • Unhealthy node के containers को reschedule किया जाता है

12.5 Logs और Diagnostics

NM प्रत्येक container के लिए logs रखता है:

  • stdout – standard output
  • stderr – error output
  • syslog – execution related logs

ये logs debugging और performance monitoring के लिए बहुत उपयोगी होते हैं।

12.6 NM Configuration Properties (yarn-site.xml)

Property Description
yarn.nodemanager.resource.memory-mb Maximum memory per NodeManager
yarn.nodemanager.vcores CPU cores available
yarn.nodemanager.log-dirs Log storage location

12.7 Real-Life Example

Netflix का एक cluster जिसमें 1,000 nodes हैं – हर node पर एक NodeManager चलता है जो movie recommendation tasks के containers को execute करता है।

12.8 Security और Isolation

  • NM containers को user isolation के साथ run करता है
  • Docker या LXC जैसे containers के माध्यम से security implement करता है

12.9 Summary

NodeManager YARN का local soldier है जो हर node पर independently resource manage करता है, execution की efficiency बढ़ाता है और ResourceManager के साथ synchronize रहकर Hadoop को मजबूत distributed platform बनाता है।

Lesson 13: ApplicationMaster – App का Control Center

ApplicationMaster (AM) YARN architecture का एक अहम component है। जब भी कोई application YARN में submit होती है, तो उसके लिए एक dedicated ApplicationMaster launch होता है, जो उस application के पूरे execution cycle को manage करता है।

13.1 ApplicationMaster क्या करता है?

  • ResourceManager से resources की request करता है – जैसे कि कितने containers चाहिए, किस resource configuration में चाहिए, आदि।
  • Tasks को schedule और monitor करता है – Job के tasks को सही container में assign करता है और उनकी progress track करता है।
  • NodeManagers से communicate करता है – Task launch, monitor और failure handling के लिए।
  • Job status track करता है – कौन से tasks complete हुए, कौन से fail हुए, retry कब करना है इत्यादि।
  • Application की final report generate करता है – Execution complete होने के बाद ResourceManager को status भेजता है।

13.2 ApplicationMaster का Lifecycle

  1. Initialization: ResourceManager AM के लिए एक container allocate करता है और NodeManager उस पर AM को launch करता है।
  2. Negotiation: AM ResourceManager से आवश्यक resources के लिए बात करता है।
  3. Execution: जब containers allocate हो जाते हैं, AM tasks launch करता है और उनके execution को monitor करता है।
  4. Completion: जब सारे tasks complete हो जाते हैं, AM ResourceManager को final status भेजता है और terminate हो जाता है।

13.3 ApplicationMaster का Failure क्या handle करता है?

  • YARN में AM के failure को भी handle किया गया है। अगर AM crash हो जाए, तो ResourceManager उसे दोबारा launch कर सकता है।
  • हर application को एक retry count assign किया जाता है। यदि retries exceed हो जाते हैं, तो application fail मानी जाती है।

13.4 ApplicationMaster vs JobTracker

ApplicationMaster JobTracker (MapReduce v1)
Per-application dedicated process Single centralized process for all jobs
Decentralized failure scope Single point of failure
Better scalability Scalability limitation due to one jobtracker

13.5 Real-World Implication:

Suppose आपकी company का एक Data Pipeline हर रात 100 GB logs को process करता है। हर night एक नया ApplicationMaster launch होता है, जो सिर्फ उसी job को handle करता है। इससे parallelism और reliability दोनों बढ़ते हैं, क्योंकि हर job isolate रहती है।

✅ Key Takeaways:

  • ApplicationMaster per-job control unit है।
  • Scheduling से लेकर execution तक सब manage करता है।
  • Failure handling और retry logic भी इसमें होता है।
  • YARN के decentralization architecture में इसका बड़ा रोल है।

Next Lesson: Lesson 14 में हम YARN Timeline Server और Monitoring architecture को detail में समझेंगे।

Lesson 14: YARN Timeline Server & Monitoring

YARN Timeline Server YARN का एक auxiliary component है, जो सभी running और completed applications का historical data store और monitor करने का काम करता है। यह real-time performance visualization और post-job analysis के लिए बेहद महत्वपूर्ण है।

14.1 Timeline Server क्या है?

  • YARN applications के lifecycle से जुड़े events, metrics, logs और अन्य metadata को collect और store करता है।
  • ResourceManager और ApplicationMaster दोनों से data लेकर एक central monitoring system में बदल देता है।
  • Job history, resource utilization, और performance trends को analyze करने की सुविधा देता है।

14.2 Timeline Server के Key Components

  1. Timeline Client: ApplicationMaster या अन्य services से data collect करता है।
  2. Timeline Collector: Client से incoming data को temporarily hold करता है।
  3. Timeline Server: Final data को persist करता है (HDFS, LevelDB या दूसरी stores में)।
  4. Web UI/REST API: Historical data को UI या external tools के माध्यम से fetch करने की सुविधा।

14.3 Monitoring क्यों ज़रूरी है?

  • Performance Tuning: Slow-running jobs या inefficient resource usage को detect करने के लिए।
  • Debugging: Task failure, bottleneck detection, और log tracing के लिए।
  • Audit Trail: किस user ने क्या job कब चलाई, इसके record के लिए (especially in secure clusters)।
  • Capacity Planning: Historical trends से future cluster resource planning में मदद।

14.4 Timeline Server v1 vs v2

Feature Timeline Server v1 Timeline Server v2
Data Structure Flat Hierarchical, scalable
Scalability Limited High (supports millions of records)
REST API Basic Advanced filtering & search

14.5 Practical Use Case:

मान लीजिए कि आपके cluster में हर दिन 100 jobs चलती हैं, और एक job बार-बार fail हो रही है। Timeline Server की मदद से आप उस job के पिछले 7 runs के data analyze कर सकते हैं — किस node पर fail हुई, कितनी memory में चली, task logs क्या थे — और root cause को trace कर सकते हैं।

🔍 Bonus Monitoring Tools:

  • Apache Ambari: Hadoop ecosystem की graphical monitoring के लिए popular tool।
  • Grafana + Prometheus: Cluster-level real-time dashboards के लिए।
  • Log Aggregation via Log4j/Splunk: Central log storage और search के लिए।

✅ Key Takeaways:

  • Timeline Server job-level historical data को capture करता है।
  • Monitoring performance, failures, and audit में मदद करता है।
  • v2 version ज्यादा scalable और advanced है।
  • External tools integration से observability और बढ़ती है।

Next Lesson: Lesson 15 में हम YARN Federation और Multi-Cluster Management की complex yet useful concept को सरल भाषा में समझेंगे।

Lesson 15: YARN Federation & Multi-Cluster Management

Hadoop YARN का मूल उद्देश्य है बड़े पैमाने पर distributed resource management। लेकिन जैसे-जैसे clusters का size और workload बढ़ता है, traditional YARN architecture scalability और isolation की limitations दिखाने लगता है। यहीं पर आता है YARN Federation, जो multiple YARN clusters को logically एक unit की तरह manage करता है।

15.1 YARN Federation क्या है?

  • YARN Federation एक advanced architecture है जो multiple ResourceManagers (clusters) को एक federated environment में जोड़ता है।
  • Clients एक ही logical interface से interact करते हैं, लेकिन actual workload अलग-अलग sub-clusters में dispatch होता है।
  • यह design scalability, isolation, और fault tolerance को improve करता है।

15.2 Federation Architecture Components

  1. Federation SubCluster: Individual YARN cluster जिसके पास अपना ResourceManager और NodeManager होते हैं।
  2. Router: Clients से request लेता है और sub-clusters को route करता है।
  3. StateStore: Sub-cluster की state, health, और application mapping को track करता है।
  4. AMRMProxy: ApplicationMaster और multiple ResourceManagers के बीच communication enable करता है।

15.3 YARN Federation के लाभ

  • Extreme Scalability: Cluster boundaries को तोड़कर लाखों nodes तक scale करना।
  • Resource Isolation: अलग-अलग teams या departments को dedicated sub-cluster assign कर सकते हैं।
  • Fault Isolation: एक sub-cluster failure बाकी workload को impact नहीं करता।
  • Geo-Distributed Clusters: Federation geographically distributed clusters को एक unit की तरह manage करता है।

15.4 Federation vs Traditional YARN

Features Traditional YARN YARN Federation
ResourceManager Single RM Multiple RMs (sub-clusters)
Scalability Limited (~10K nodes) Massive (~100K+ nodes)
Fault Isolation Low High
Application Routing Centralized Dynamic via Router

15.5 Practical Use Case:

मान लीजिए एक multinational organization है जिसके पास India, USA और Germany में अलग-अलग data centers हैं। हर जगह का workload और compliance अलग है। Federation इन सब clusters को logically unify करता है और central policy-based access allow करता है। साथ ही disaster recovery और data sovereignty भी maintain होती है।

15.6 Challenges in YARN Federation

  • Complex Setup: Multiple moving components (Router, AMRMProxy, StateStore) के साथ configuration intricate हो जाती है।
  • Security: Multi-cluster authentication & authorization काफी advanced planning मांगता है।
  • Monitoring: अलग-अलग clusters का centralized monitoring करना complex हो सकता है।

🔍 Bonus Tips:

  • Router को high availability mode में deploy करें।
  • Federation के साथ integrated monitoring के लिए Apache Ambari या Grafana-based solution use करें।
  • Initial testing के लिए 2 small clusters को federate कर practice करें।

✅ Key Takeaways:

  • YARN Federation large-scale enterprise environments के लिए ideal solution है।
  • यह resource sharing, isolation, और geographic scalability को simplify करता है।
  • Proper setup और testing के साथ Federation production-ready बन सकता है।

Next Lesson: Lesson 16 में हम YARN Resource Preemption के advanced topic को विस्तार से समझेंगे — जिसमें resource guarantees, fairness और抢占 logic शामिल है।

Lesson 16: YARN Resource Preemption

Hadoop YARN में resource allocation fairness और efficiency बनाए रखने के लिए Resource Preemption एक बेहद महत्वपूर्ण feature है। जब कोई high-priority application को जरूरी resources नहीं मिलते और low-priority applications already उन resources को occupy करते हैं, तब YARN preemption के ज़रिए उन्हें वापस लेकर critical tasks को assign करता है।

16.1 Resource Preemption क्या है?

  • यह YARN का एक mechanism है जो under-served applications के लिए resources को forcibly reclaim करता है।
  • Preemption तब activate होती है जब कोई application अपनी guaranteed capacity के नीचे चल रही हो।
  • यह केवल Capacity Scheduler में supported है।

16.2 Preemption कैसे काम करता है?

  1. Scheduler Analysis: YARN हर 500ms में cluster की resource utilization check करता है।
  2. Under-Served Queue Detect: अगर कोई queue अपनी guaranteed capacity नहीं पा रही है, तो वह preemption के लिए eligible बनती है।
  3. Victim Container Identification: Low-priority queues से ऐसे containers चुने जाते हैं जिन्हें terminate करके resources free कराए जा सकें।
  4. Preemption Execution: Selected containers को kill करके high-priority queue को resources allocate किए जाते हैं।

16.3 Key Configurations

Property Description Default
yarn.resourcemanager.scheduler.monitor.enable Preemption को enable करता है false
yarn.scheduler.capacity.resource-calculator Resource calculations को define करता है DefaultResourceCalculator
yarn.resourcemanager.monitor.capacity.preemption.max-total-preemption-percentage Max percentage resources जो preempt हो सकते हैं 0.2

16.4 Resource Preemption का लाभ

  • Fairness: हर application को उसकी guaranteed capacity मिलती है।
  • Service Level Agreement (SLA) Protection: High-priority jobs time पर complete हो पाती हैं।
  • Efficient Resource Utilization: Idle और misuse होने वाले resources को reclaim किया जाता है।

16.5 Challenges of Preemption

  • Forceful container termination से कुछ applications fail हो सकते हैं।
  • Latency-sensitive applications (जैसे Spark Streaming) पर preemption का असर पड़ सकता है।
  • Proper tuning जरूरी है ताकि unnecessary preemption न हो।

16.6 Real-World Scenario:

मान लीजिए एक cluster में दो queues हैं — queue-a (Production) और queue-b (Dev)। अगर Production queue को 60% capacity मिलनी है लेकिन Dev queue ने 70% occupy कर रखा है, और Production को urgent job run करनी है, तो YARN Dev queue से कुछ containers kill करके Production को allocate करता है।

🔧 Best Practices for Preemption

  • Scheduler configuration को clearly define करें — capacity, priority, and user access।
  • Sensitive jobs के लिए "preemption-disabled" tags use करें (जहां supported हो)।
  • Monitoring tools जैसे Grafana या Cloudera Manager से track करें कि कौनसे containers preempt हो रहे हैं।

✅ Key Takeaways

  • YARN Preemption fairness और workload balance बनाए रखने का core mechanism है।
  • यह केवल Capacity Scheduler में काम करता है — Fair Scheduler में नहीं।
  • Proper configuration और testing से unwanted failures को रोका जा सकता है।

Next Lesson: Lesson 17 में हम YARN Resource Localization के बारे में सीखेंगे — जिसमें समझेंगे कि application-specific files और data को nodes पर कैसे manage किया जाता है।

Lesson 17: YARN Resource Localization क्या होता है?

Resource Localization YARN का एक ऐसा प्रोसेस है जिसमें एप्लिकेशन को रन करने के लिए आवश्यक फाइल्स और डिपेंडेंसीज़ को Node Manager द्वारा लोकल मशीन पर लाया जाता है। ये फाइलें आमतौर पर HDFS या shared file system में स्टोर होती हैं।

🔍 Resource Localization क्यों ज़रूरी है?

  • जब YARN एप्लिकेशन स्टार्ट होता है, तो AppMaster और Containers को कुछ libraries, scripts, या JAR files की ज़रूरत होती है।
  • ये फाइलें HDFS या किसी अन्य remote system में होती हैं, इसलिए उन्हें लोकल मशीन पर कॉपी करना जरूरी होता है जहां container execute होगा।

🛠️ Resource Localization का Workflow

  1. Application Submission के समय Resource details (जैसे paths, size) define किए जाते हैं।
  2. NodeManager एक localized cache बनाता है जहां ये files कॉपी की जाती हैं।
  3. Container execution से पहले NM validate करता है कि resource available और accessible है या नहीं।

📂 Resource के Types

  • File: Script, config, jar, binary, etc.
  • Archive: .tar, .zip, .jar जिन्हें extract करके use किया जाता है।

🎯 Resource Visibility Levels

Visibility Meaning
PUBLIC कोई भी एप्लिकेशन इस resource को use कर सकता है
PRIVATE सिर्फ उसी एप्लिकेशन द्वारा use किया जा सकता है जिसने इसे submit किया है
APPLICATION सिर्फ उस app-specific container के लिए visible

⚠️ Common Issues in Localization

  • Permission Denied Error (Visibility सही set नहीं किया गया)
  • Insufficient Disk Space on Node
  • Resource not found or inaccessible path

💡 Real Example

मान लीजिए आपने एक Spark application deploy किया है और उसमे एक Custom JAR की जरूरत है जो HDFS में /apps/libs/myjar.jar पर है।
AppMaster और Containers को उस JAR को एक्सेस करने से पहले, NM उस JAR को HDFS से fetch करेगा और लोकल path पर store करेगा। तभी container रन कर पाएगा।

✅ Localization में Optimization के तरीके

  • Resources को compress करके upload करें (.tar, .zip)
  • Repeated use वाले resources को PUBLIC visibility दें
  • Unused resources को cleanup करने के लिए cleanup script यूज़ करें
📘 Expert Quote:
"Resource Localization is the silent backbone of YARN's distributed execution. Without efficient localization, containers can't even begin to run." — Apache Docs Contributor

अगले lesson में हम देखेंगे: YARN Application Submission का पूरा flow — step-by-step!

Lesson 18: YARN Application Submission Flow – पूरी प्रक्रिया Step-by-Step

YARN में किसी भी एप्लिकेशन को रन कराने की प्रक्रिया को Application Submission Flow कहते हैं। यह एक multi-stage process है जिसमें client, ResourceManager, और NodeManager मिलकर एक distributed application को execute करते हैं।

🚀 Step-by-Step Application Submission Process

  1. Client → ResourceManager
    Client सबसे पहले YARN ResourceManager को एक Application Request भेजता है। इसमें memory, CPU, और अन्य configuration details होती हैं।
  2. Application ID Assignment
    ResourceManager client को एक unique Application ID return करता है जो उस app को uniquely identify करता है।
  3. Application Submission Context
    Client अब ResourceManager को Application Submission Context भेजता है जिसमें होता है:
    • ApplicationMaster launch command
    • Local resources (JARs, configs)
    • Environment variables
    • Resource requirements
  4. ResourceManager → Scheduler
    RM यह जानकारी Scheduler को देता है कि एक ApplicationMaster को launch करना है। Scheduler available resources को check करता है।
  5. Container Allocation
    जैसे ही कोई NodeManager पर resource available होता है, Scheduler एक container allocate करता है ApplicationMaster के लिए।
  6. ApplicationMaster Launch
    ResourceManager → NodeManager को command देता है कि वो उस container में ApplicationMaster को launch करे।
  7. AM → RM Registration
    ApplicationMaster खुद को ResourceManager के पास register करता है, ताकि वह नए containers मांग सके।
  8. Task Resource Request
    ApplicationMaster अब अपने task-specific containers के लिए ResourceManager से request करता है।
  9. Containers Allocation & Launch
    Scheduler containers allocate करता है और NodeManager उन containers में tasks को launch करता है।
  10. Progress Monitoring & Completion
    ApplicationMaster पूरे execution को monitor करता है, और जैसे ही सारे tasks complete हो जाते हैं, वो खुद को ResourceManager से deregister कर देता है।

🧠 Visualization:

Client → RM → NM → AM → RM → NM → Containers → Completion

📌 Key Points to Remember

  • ApplicationMaster हर एप्लिकेशन के लिए अलग होता है
  • Client सिर्फ request भेजता है, पूरा control ApplicationMaster के पास होता है
  • ResourceManager centralized होता है लेकिन NodeManagers distributed होते हैं

📘 Real-World Insight

अगर आप Spark, Tez, या MapReduce एप्लिकेशन चलाते हैं, तो YARN की यह पूरी submission प्रक्रिया आपके पीछे silent रूप से काम करती है। Performance tuning का बड़ा हिस्सा इसी flow को optimize करने से जुड़ा होता है।

✅ Bonus Tip:

  • आप Client से एप्लिकेशन submit करते समय --files, --archives, और --conf जैसे flags का उपयोग कर सकते हैं
  • ApplicationMaster logs HDFS पर या NodeManager पर available होते हैं
📘 Final Summary:
आपने YARN के architecture से लेकर ApplicationMaster, Containers, Scheduler, ResourceManager, और अब Application Submission Flow तक हर महत्वपूर्ण component और process को सीखा। यह guide Hadoop YARN को production-level समझने के लिए sufficient foundation देता है।

📣 Final CTA (Call to Action)

अगर आपको यह पोस्ट पसंद आई हो और आप इसी तरह की deep और structured learning series चाहते हैं तो नीचे कमेंट करें।

❓ अक्सर पूछे जाने वाले सवाल (FAQ)

1. YARN क्या है?

YARN (Yet Another Resource Negotiator) Hadoop का resource management layer है जो cluster में resource allocation और job scheduling को manage करता है।

2. YARN में ApplicationMaster क्या काम करता है?

ApplicationMaster किसी भी application के execution को manage करता है। यह ResourceManager से resource मांगता है और NodeManager पर tasks को launch करता है।

3. ResourceManager और NodeManager में क्या अंतर है?

ResourceManager cluster का centralized resource allocator होता है जबकि NodeManager हर node पर चलता है और resource utilization को manage करता है।

4. YARN के कितने प्रकार के schedulers होते हैं?

YARN में मुख्य रूप से तीन प्रकार के scheduler होते हैं: FIFO Scheduler, Capacity Scheduler और Fair Scheduler।

5. Application Submission Flow क्यों जरूरी है?

यह flow बताता है कि किसी भी distributed application को YARN में कैसे submit किया जाता है, कैसे resources allocate होते हैं और कैसे task execution होता है।

Post a Comment

Blogger

Your Comment Will be Show after Approval , Thanks

Ads

 
↑ Top