Load Balancing Methods & Persistence

F5 BIG-IP LTM F5 BIG-IP VE (GUI + TMSH)

مقصدObjectiveObjective

اس سبق میں آپ لوڈ بیلنسنگ کا طریقہ least-connections پر بدلیں گے اور source-address اور cookie persistence شامل کریں گے۔Is lesson mein aap load balancing ka tareeqa least-connections par badlenge aur source-address aur cookie persistence shamil karenge.In this lesson you will change the load balancing method to least-connections and add source-address and cookie persistence.

آسان مثالSimple AnalogySimple Analogy

Round Robin ایسا ہے جیسے ہر کھلاڑی کو برابر تاش بانٹے ہوں۔ Least Connections ایسا ہے جیسے کیشئر کی لائن میں نیا گاہک سب سے چھوٹی قطار میں لگ جاتا ہے۔Round Robin aisa hai jaise har khiladi ko barabar taash bante hon. Least Connections aisa hai jaise cashier ki line mein naya gahak sab se chhoti qataar mein lag jata hai.Round Robin is like dealing cards equally to each player. Least Connections is like the cashier line where the new customer joins the shortest queue.

سیٹ اپLab SetupLab Setup

BIG-IP VE پچھلے سبق کے web-pool (دو members) اور web-vip کے ساتھ۔BIG-IP VE pichlay lessons ke web-pool (do members) aur web-vip ke sath.BIG-IP VE with web-pool (two members) and web-vip from previous lessons.

اقداماتStepsSteps

Step 1

Pool کے لوڈ بیلنسنگ کا طریقہ least-connections پر بدلیں۔ اب BIG-IP ہر نئی درخواست اس member کو بھیجے گا جس کے پاس سب سے کم active connections ہوں۔Pool ke load balancing ka tareeqa least-connections par badlen. Ab BIG-IP har nayi request us member ko bhejega jis ke paas sab se kam active connections hon.Change the pool's load balancing method to least-connections. Now the BIG-IP sends each new request to the member with the fewest active connections.

tmsh modify ltm pool web-pool load-balancing-mode least-connections-member

🖱️ Local Traffic > Pools > web-pool — Load Balancing MethodLocal Traffic > Pools > web-pool — Load Balancing MethodLocal Traffic > Pools > web-pool — Load Balancing Method

Step 2

Pool میں source-address persistence شامل کریں۔ اس ایک IP کا کلائنٹ ہمیشہ اسی سرور پر بھیجا جائے گا۔Pool mein source-address persistence shamil karein. Us ek IP ka client hamesha usi server par bheja jayega.Add source-address persistence to the pool. The same client IP is always sent to the same server.

tmsh create ltm persistence source-addr src-persist
tmsh modify ltm pool web-pool persist replace-all-with { src-persist }

🖱️ Local Traffic > Profiles > Persistence > Create، پھر ورچوئل سرور سے جوڑ دیںLocal Traffic > Profiles > Persistence > Create, phir virtual server se jor deinLocal Traffic > Profiles > Persistence > Create, then attach to the virtual server

Step 3

Cookie persistence کلائنٹ کے براؤزر میں ایک LTM cookie لگاتی ہے تاکہ NAT کے پیچھے ہونے کے باوجود requests اسی سرور پر واپس آئیں۔Cookie persistence client ke browser mein ek LTM cookie lagati hai taake NAT ke peechay hone ke bawajood requests usi server par wapas aayen.Cookie persistence inserts an LTM cookie in the client's browser so requests return to the same server even behind NAT.

tmsh create ltm persistence cookie cookie-persist

🖱️ Local Traffic > Profiles > Persistence > Create (Cookie)Local Traffic > Profiles > Persistence > Create (Cookie)Local Traffic > Profiles > Persistence > Create (Cookie)

Step 4

Cookie کا ٹیسٹ کریں: اسی کلائنٹ سے بار بار requests اسی سرور پر آنی چاہئیں۔Cookie ka test karein: usi client se baar baar requests usi server par aani chahiyen.Test the cookie: repeated requests from the same client should keep landing on the same server.

curl -I http://172.16.1.100 | grep Set-Cookie

Step 5

Pool کی آخری کنفیگریشن دیکھیں: لوڈ بیلنسنگ کا طریقہ اور attached persistence۔Pool ki aakhri configuration dekhen: load balancing ka tareeqa aur attached persistence.Review the final pool configuration: load balancing method and persistence attached.

tmsh list ltm pool web-pool one-line

Step 6

عام اصول: HTTP ایپس کے لیے cookie persistence اور non-HTTP یا آسان صورتِ حال کے لیے source-address استعمال کریں۔Aam usool: HTTP apps ke liye cookie persistence aur non-HTTP ya aasan surat-e-haal ke liye source-address istemal karein.Rule of thumb: use cookie persistence for HTTP apps and source-address for non-HTTP or simple cases.

تصدیقVerifyVerify

تصدیق: لوڈ بیلنسنگ کا طریقہ least-connections دکھاتا ہے، اور بار بار curl requests ایک ہی سرور پر جاتی ہیں۔Tasdeeq: load balancing ka tareeqa least-connections dikhata hai, aur baar baar curl requests ek hi server par jati hain.Verify: load balancing method shows least-connections, and repeated curl requests stick to one server.

tmsh list ltm pool web-pool
tmsh show ltm pool web-pool members

خرابی دور کرناTroubleshootingTroubleshooting

⚠️ Persistence کام نہیں کر رہی — requests مختلف سرورز پر جا رہی ہیںPersistence kaam nahi kar rahi — requests mukhtalif servers par ja rahi hainPersistence not working — requests hit different servers

✅ چیک کریں کہ persistence پروفائل واقعی ورچوئل سرور سے جڑی ہے، اور matching persistence entry timeout تو نہیں ہو رہی۔Check karein ke persistence profile waqei virtual server se juri hai, aur matching persistence entry timeout to nahi ho rahi.Check that the persistence profile is actually attached to the virtual server, and that a matching persistence entry is not timing out.

⚠️ Least-connections برابر نہیں بانٹ رہاLeast-connections barabar nahi bant rahaLeast-connections not distributing evenly

✅ لمبی چلنے والی کنکشنز ڈیزائن کے لحاظ سے ایک member پر رہتی ہیں — یہ عام بات ہے؛ request کی تعداد کے بجائے ہر member کی connection کی تعداد دیکھیں۔Lambi chalne wali connections design ke lehaz se ek member par rehti hain — yeh aam baat hai; request ki tadad ke bajaye har member ki connection ki tadad dekhen.Long-lived connections stay on one member by design — this is normal; check connection counts per member, not request counts.

انٹرویو سوالاتInterview Q&AInterview Q&A

❓ Source-address persistence اور cookie persistence میں کیا فرق ہے؟Source-address persistence aur cookie persistence mein kya farq hai?What is the difference between source-address persistence and cookie persistence?

Source address persistence کلائنٹ کو IP کی بنیاد پر اسی سرور پر بھیجتی ہے — آسان لیکن NAT میں ٹوٹ جاتی ہے۔ Cookie persistence LTM cookie لگاتی ہے، جو NAT کے باوجود کام کرتا ہے۔Source address persistence client ko IP ki bunyad par usi server par bhejti hai — aasan lekin NAT mein toot jati hai. Cookie persistence LTM cookie lagati hai, jo NAT ke bawajood kaam karta hai.Source address persistence sends a client to the same server based on IP — simple but breaks with NAT. Cookie persistence inserts an LTM cookie, which works even through NAT.