IITM SE · Week 10
Software Engineering · Week 10

Software Deployment
aur Monitoring

Code likh liya, test bhi kar liya — ab usse duniya tak pahunchana kaise hai, aur pahuchane ke baad zinda kaise rakhna hai. Poore week ke 6 lectures + slides ke notes, Hinglish mein.

01
Dev
02
Testing
03
Staging
04
Production
Code ka safar — laptop se lekar live users tak
Week ka map

6 videos, 4 bade topics:

  1. Deployment Environments & Strategies — Dev, Testing, Staging, Production + Blue/Green, Canary, Versioned
  2. Deployment Hosting — Bare Metal vs IaaS vs PaaS
  3. Tutorials — DigitalOcean (IaaS) aur Heroku (PaaS)
  4. Continuous Integration — process + 7 best practices
  5. Performance & Monitoring — caching, task queues, page load, monitoring tools, A/B testing
Do definitions jo poora week chalati hain

Deployment = jo software system humne banaya hai, use aise "place" karna ki end users easily access kar saken (jaise web app ko server pe host karna, aur user URL se khole).

Monitoring = deployed application ki execution information ko capture aur analyze karna — users kaise use kar rahe hain, performance issues, errors, timeouts vagairah.

01

Deployment Environments

Sabse pehle ek word samajh lo: Environment = wo system (ya systems ka set) jo ek given software application ko execute karta hai. Developer code likhta hai, environment usse build karke executable banata hai jise log access karte hain.

Char types hote hain. Lecture mein ek important line hai: development, testing aur production toh usually har team ke paas hote hi hain — staging optional-ish hai par best practice hai.

01 · Development

Developer ka local machine

  • Individual developer ka apna laptop/PC, jisme IDE aur baaki tools hote hain
  • Yahan wo code likhta hai, run karta hai, unit test karta hai, build karta hai
  • Uske code ko bolte hain working copy; shared repo ko bolte hain mainline / master branch
  • Commit ke time conflicts check karne padte hain (kisi aur ne same file badli ho toh)
  • Local DB se connected — real data kharab hone ka dar nahi
02 · Testing

Yahan integration + system testing hoti hai

  • Repository ka code yahan deploy hota hai
  • Test fail hua toh: defect wala code test env se hata diya jata hai
  • Jis module mein failure hua, wo identify hota hai, aur us module ka developer notify hota hai
  • Code previous working version pe roll back kiya jata hai
  • Developer apni working copy mein fix karke commit karta hai → next scheduled deployment mein wapas test env mein aata hai
03 · Staging

Pre-production — production ka hubahu copy

  • Exactly resembles production — hardware, software, configurations sab same
  • Remote machine pe chalta hai, dev team ke local network pe nahi
  • Isko pre-production environment bhi bolte hain
04 · Production

Live environment

  • Jahan actual users software ko access karte hain, real data hota hai
  • Naya feature aaya? Poora lifecycle dobara: design → develop → commit → testing → staging → production
  • Staging se production tak code smoothly le jaane ke liye ek strategy chahiye — aage padho
Reflection Spot (slide 8)

Staging environment ki zarurat kyu? Seedha production pe push kyu nahi kar dete? — 30 second socho, phir neeche padho.

Staging kyu chahiye — 3 solid reasons

  1. Deployment mein bahut saari activities aur configurations hoti hain — libraries install, packages configure, scripts run (jaise DB initialize). Agar ye sab seedha production pe kiya aur kuch galat ho gaya, toh live system crash ho sakta hai aur real users affect honge. Staging mein pehle test karo, phir wahi steps production pe repeat karo (kyunki staging production ki replica hai).
  2. New features ka preview — management, sales/marketing teams, ya kuch selected potential clients ko naya feature dikhana ho, par sabko rollout nahi karna — staging pe dikha do.
  3. Performance / stress testing — ye local machine ya testing environment pe theek se nahi ho sakti, live-jaisa environment chahiye. Aur production pe karoge toh actual users disturb honge. Isliye staging perfect jagah hai.
Exam pointer

"Unit testing" ka jawab hamesha Development environment hai. "Integration + System testing" ka jawab Testing environment. "Performance/stress testing" ka jawab Staging. Ye teen alag-alag hain — MCQ mein exactly yahi ghumaya jata hai.

02

Deployment Strategies

Staging se production tak code push karne ke tareeke. Teen strategies padhni hain: Blue/Green, Canary, aur Versioned.

Router Console — teeno strategies live chalao

Har dot ek user hai. Neeche tab select karo aur buttons dabao — router traffic kaise route karta hai, dekho.

Blue / Green
Canary
Versioned
ROUTER
BLUE (current)
v1.0
100% traffic
GREEN (new)
v2.0
0% traffic
Blue live hai. Green pe naya version deploy hai par abhi koi user nahi.

Blue/Green Deployment (Staged Deployment)

New version ke liye ek alag naya production environment banao, current wale ko chhue bina. Blue = abhi ka live production. Green = naya version.

Canary Deployment (Phased / Incremental Rollout)

Blue/Green jaisa hi, par ek go mein sabko nahi — users ke chhote subset ko dheere-dheere naya version diya jata hai.

Versioned Deployment

Users ko khud version choose karne do. Saare versions alive rakhe jaate hain. User update kar le toh use new version pe route kar do, warna wo purane pe hi raha.

StrategyIdeaPlusMinus
Blue/GreenNaye version ke liye poora alag production env, phir router switchRollback easyDo full environments maintain karne padte hain
CanaryChhote user subset ko phased rollout (random / profile / region)Risk kam, real users pe testMultiple instances ek saath manage karne padte hain
VersionedUser khud version chunta hai, sab versions aliveUser ko choice, forced update nahiMultiple versions maintain karna padta hai
Confusion trap

Blue/Green aur Canary dono naye environment pe deploy karte hain — farq sirf itna hai ki traffic kitna shift hota hai. Blue/Green = sab ek saath. Canary = thoda-thoda. Aur A/B testing (aage aayega) canary deployment pe hi chalti hai.

03

Deployment Hosting

Hosting = wo infrastructure jo applications ko host/deploy karne ke liye chahiye. Web apps usually server systems pe host hoti hain, clients wahan se service access karte hain.

Sabse important characteristic

Server 24×7, poore saal, bina unplanned downtime ke available rehna chahiye — khaaskar production mein, jahan real users aur real data hote hain. Data secure bhi rehna chahiye.

Teen hosting options — kaun sa layer kaun sambhalta hai

Neeche har option mein 4 layers hain: Server Hardware → Operating System → Web Server → Web Application. Jitne zyada layer aapke, utna control; jitne kam, utni asaani.

Bare Metal

Sab kuch aapka
Web Application
Web Server
Operating System
Server Hardware

IaaS

Hardware + OS provider ka
Web Application
Web Server
Operating System
Server Hardware

PaaS

Sirf app aapki
Web Application
Web Server
Operating System
Server Hardware
Aap manage karte ho Provider manage karta hai

1. Bare Metal Servers

2. Infrastructure-as-a-Service (IaaS)

3. Platform-as-a-Service (PaaS)

 Bare MetalIaaSPaaS
Aap manage karte hoHardware, OS, web server, appWeb server, appSirf app
ExamplesApne rack/blade serversDigitalOcean, AWS, LinodeHeroku, Google App Engine
AdvantageHighest performanceCheaper, no maintenance overheadVery easy to deploy
DisadvantageMost expensive upfront + setup/maintenance effortApni-apni configurations; shared → performance sufferLack of control
04

Tutorials — DigitalOcean & Heroku

IaaS Tutorial — DigitalOcean

DigitalOcean humein hardware + operating system deta hai apni app host karne ke liye.

Yaad rakhne wala word

Droplet = DigitalOcean ka virtual machine ke liye term. (Video wale droplet mein 1 GB memory, 25 GB disk, Ubuntu 18.04 tha.)

Dashboard se bandwidth, CPU usage, disk I/O — sab monitor kar sakte ho.

Droplet banane ke steps (video ke hisaab se):

  1. Account banao / login karo, aur ek project create karo
  2. Region chuno — video mein Bangalore data center, kyunki wo humare closest hai
  3. OS aur version chuno
  4. Droplet type chuno — simple apps ke liye basic droplet kaafi hai; CPU options regular / premium Intel / AMD; shared CPU vs dedicated CPU ka farq hota hai. Blogs, discussion forums, chhote projects ke liye basic theek. (Ek range hoti hai — upar 256 GB RAM, 4.69 TB storage tak; minimum lagbhag $6/month.) Extra storage bhi add kar sakte ho.
  5. Authentication method chuno — SSH key (terminal se connect) ya password. Monitoring aur backups enable kar sakte ho.
  6. Droplet ban gaya → usi credentials se login karo → GitHub se code checkout karo, web server + database server set karo, application run karo — bilkul waise hi jaise local system pe karte ho.

PaaS Tutorial — Heroku (Flask app)

Ek simple Flask app (ek route, "hello world") ko Heroku pe deploy karne ka poora flow:

Part A — App ko taiyaar karo

  1. Virtual environment banao aur activate karo, taaki packages system ke baaki packages se conflict na karein
  2. pip install flask gunicorngunicorn ek Web Server Gateway Interface (WSGI) hai, jise Heroku Python apps deploy karne ke liye use karta hai
  3. pip freeze > requirements.txt — ismein saare packages aur unke version numbers aa jaate hain. Heroku isi file ko dekh kar modules install karta hai
  4. Procfile banao — ye Heroku ko batata hai ki application kaise run karni hai: ye ek web app hai, gunicorn web server use karo, aur app.py ke andar jo app variable hai use chalao

Do zaroori files: requirements.txt + Procfile.

Part B — Deploy karo (Heroku CLI se)

heroku login          # browser khulega, login karo
git init              # project mein git repo initialize
heroku git:remote -a <app-name>   # heroku ko remote repo bana do
git add Procfile app.py requirements.txt
git commit -m "initial commit"
git push heroku master   # push + deployment dono

Push karte hi remote pe build shuru: Python install, pip install, requirements.txt ke saare packages install; Procfile se samajh liya ki ye web app hai → launch → deployed. URL browser mein kholo, app chal rahi hogi.

Code change karna ho? Normal git process: file badlo → git addgit commitgit push heroku master. Har push pe wo commit bhi karega aur build+deploy bhi. Heroku dashboard pe build succeeded dikh jayega; metrics ke liye credit card chahiye; extra resources (data stores, caching, CMS) bhi add kar sakte ho. Google App Engine bhi similar process follow karta hai.

05

Continuous Integration

Deployment kitna important aur time-consuming hai ye ab tak samajh aa gaya — multiple logon ka code integrate karo, sufficiently test karo, aur bina bugs ke live environment pe sahi se deploy karo. CI = integration aur deployment process ko automate karna.

🗄️
Version Control System
⚙️
CI Server
🚀
Staging / Deployment Server
  • 1Developer code commit karta hai version control system mein
  • 2CI server naya code pull karta hai
  • 3CI server code build aur test karta hai — unit + integration tests, errors check — sab automatic
  • 4Koi error nahi → deployment/staging server ko message: ready to deploy
  • 5Deployment server version control se code pull karta hai
  • 6Ek aur round build, test — phir deploy
  • 7CI server ko notify: deployment complete

7 Best Practices for Continuous Integration

Ye exam mein list ke roop mein poochha jata hai — dohra lo.

01

Maintain a single source repository

Ek mainline / master branch rakho. Zyada log, zyada time isi branch pe kaam karein. New features ya bug fixes ke liye thodi branches chalengi, par default master hi ho.

02

Automate the build

Build mein compilation, files copy/move karna, database schemas banana — sab aata hai. Ye sab build tools se automate karo. Java mein Ant aur Gradle, Node.js mein Builder. Bas sahi configuration ke scripts likhne padte hain.

03

Make the build self-testing

Automated tests banao jo code base ke bade hisse ko bugs ke liye check karein. Ek simple command test suite chala de. Test fail ho toh us module ke responsible developer ko notification jaana chahiye.

04

Commit to the main branch every day

Kam commit karoge toh conflict errors zyada aayenge (jab doosron ne wahi code badla ho). Frequent commits developers ko kaam chhote-chhote chunks mein todne ke liye encourage karte hain.

05

Har commit mainline ko integration server pe build kare

CI server repository ko monitor karta hai. Commit hote hi naya code pull, build, integration testing, aur committer ko notify — sab pass toh build successful.

06

Fix broken builds immediately

Broken build fix karna developers ki priority honi chahiye. Aur system ko last-known good build pe wapas le jaao, taaki baaki developers ko sahi code base mile aur error unke code tak na phaile.

07

Automate deployment

Deployment ko automate karne wale scripts likho — jaise staging environment pe deployment. Isse latest code hamesha staging pe available rehta hai.

CI Server examples

JenkinsCruiseControl — CruiseControl ka dashboard builds ki list dikhata hai: kaunse pass/fail hue, kitni duration lagi, kisne modifications kiye, waghera.

Build tools alag hain: AntGradleBuilder — inhe CI servers ke saath mat mila dena.

Reflection Spot (slide 41)

Continuous Integration ke benefits kya hain — end users ke liye, developers ke liye, organization ke liye?

Benefits of CI

Drawback of CI

Sirf ek: processes set up karne ka initial effort — integration server lagana, logon ko train karna, sab mein time lagta hai. Par zyadatar cases mein advantages drawbacks se kahin zyada hain.

06

Performance improve karne ke tareeke

Code deploy ho gaya — ab performance acceptable standards pe honi chahiye. Teen bade tareeke: Caching, Task Queues, aur pages ko jaldi load/render karna.

1. Caching

Common operations ke results ko memory mein store kar lena, taaki har baar database se na laana pade. Memory se lana zyada fast hai aur servers pe load kam hota hai. Common queries agar baar-baar chalti hain aur DB mein koi change nahi hua, toh memory se serve kar do.

Tools: MemcachedRedis

Caching ke 3 levels

  1. Web browser cache — pehle visit ki gayi pages ki copy rakhta hai. Server se verify karke ki page badla nahi, browser cache se hi page load kar leta hai.
  2. Web server — page cache — database access kiye bina, server apne cache se stored web page client ko bhej deta hai.
  3. Database — query cache — recent queries ke results jo change nahi hue. DB dobara query chalane ke bajaye query cache se result web server ko, aur web server client ko de deta hai.

Demo: cache hit vs database fetch

Database se
0 ms
Cache (memory) se
0 ms

2. Task Queues

Application badi hoti hai toh bahut saare resource aur time consuming tasks aate hain — hazaron users ko email/notification bhejna, bulk database records create/update karna (jaise user delete karo toh uska saara associated data delete karo). Ye tasks turant execute karna zaroori nahi — user ko bata do ki ho jayega aur baad mein notification bhej do.

Iske liye asynchronous work queue use hoti hai. Asynchronous isliye kyunki ye normal HTTP request–response cycle ke bahar execute hoti hai.

Kyu zaroori hai? Normal cycle mein: request → server process kare → email bheje → response de. Par hazaron users ko email bhejne ke liye user ko itni der wait nahi karwa sakte. Isliye task queue mein daal do.

Work queue ke 2 hisse

Queue of jobs (+ parameters)
Pool of workers

Note: ek nahi, kai workers queue se jobs uthate hain aur kaam baant lete hain → bahut kam time. Aur agar zyada traffic expect kar rahe ho toh workers ka pool dynamically badha sakte ho.

3. Loading & Rendering Pages Faster

Web apps mein bahut saara static content hota hai — HTML, CSS, JavaScript, images. Inka jaldi load hona bahut zaroori hai.

Kyu? Kyunki evidence hai: mobile delays se hone wala stress level horror movie dekhne ke barabar hota hai (Ericsson study wali famous slide). Users bas kuch seconds extra mein hi uncomfortable aur agitated ho jaate hain.

Business impact

2016: AliExpress ne apni site ki speed 30% badhayi → customer orders 10.5% badh gaye.

Business impact

2006: Google ne search results ko sirf half a second slow kiya → user requests 25% gir gaye.

Tareeka A — Minify your code

Minify matlab code se saare spaces, tabs, extra white-space hata dena (aur parameter names tak chhote kar dena). Slide wale simple Fahrenheit→Celsius JavaScript function mein hi ~41% ki saving hui — aur ye toh ek chhota function tha. Poori site pe ye add up hoke bada farq banata hai.

Original
function ftoc(f) {
    var celsius = (f - 32) * 5 / 9;
    return celsius;
}
Minified
— minify dabao —
0% size saving

Tareeka B — Compress static pages

Static pages ko compress karo. Tools: BrotliGzip

07

Monitoring

Testing aur staging mein sab theek tha, phir bhi live environment mein issues aa sakte hain. Isliye deploy ke baad constant monitoring zaroori hai.

Kya-kya monitor karte hain

Resource

CPU utilization

Peak times pe CPU kitna use ho raha hai?

Resource

Memory utilization

RAM par kitna load aa raha hai?

Resource

Storage — consumed vs free

Database-intensive activities se disk bhar gaya toh naya data add nahi hoga → users ko errors.

Network

Bandwidth & latency

Latency = user ko response milne mein kitna time lagta hai. Periodically check karna padta hai.

In sab ke basis pe development aur operations teams respond karke problems fix karti hain.

Monitoring Tools — Report generating tools

Inhe URL do, ye page resources analyze karke optimization suggestions dete hain, SEO aur accessibility metrics check karte hain, aur ek performance score calculate karte hain.

Example: Lighthouse — Google ki service, Chrome extension ke roop mein install hoti hai. Speed index jaise kai metrics deti hai.

Monitoring to understand Customer Behaviour

MetricMatlab
ClickstreamsUsers sabse zyada kaun se page sequences visit karte hain? Website mein kai paths hote hain — kaun sa path sabse zyada liya ja raha hai?
Think time / Dwell timeEk typical user ek given page pe kitni der rukta hai?
AbandonmentEk flow ko beech mein chhodne wale users ka percentage. Slide ka flow: Product page → Buy Now → Add address → Add payment → Pay. Flow complete karna business ke liye desirable hai; beech mein chhodna = us customer ka business loss.

Analytics Tools

Kaam kaise karte hain: site ke har page mein JavaScript ka chhota piece embed kar do. Ismein tracking code hota hai jo page load hote hi information analytics tool ko bhej deta hai.

Example: Google Analytics — har interaction ke baad ke metrics deta hai, kahan drop-off ho raha hai wo bhi. Bas account sign up karo aur proper tracking code website mein daal do.

Monitoring for A/B Testing

Version A mein kuch issues hain (maan lo abandonment zyada hai). Toh Version B banao — naya workflow ya better UI. Ab canary deployment (incremental rollout) karo: kuch users ko A, kuch ko B.

Dono versions monitor karo aur dekho kaun better hai. "Better" ka matlab ho sakta hai: zyada traffic, zyada dwell time, zyada sales, kam abandonment.

Link yaad rakho

A/B testing = Canary deployment + Monitoring metrics. Ye do topics ka joint question ban sakta hai.

08

One-page Cheat Sheet

Quiz se 10 minute pehle bas ye padh lo.

ConceptEk line mein
Development envDeveloper ka local machine + IDE + local DB; unit testing yahan
Testing envIntegration + system testing; fail hua toh code hatao, developer notify, previous version pe rollback
Staging envProduction ki exact replica, remote machine; pre-production; performance/stress testing + feature preview
Production envLive environment, real users, real data
Blue/GreenNaya alag production env; router se full switch; rollback easy; blue-green cycle karte hain
CanaryChhote subset ko phased rollout (random/profile/demographics/region); multiple instances manage karna padta hai
VersionedUser version chunta hai, sab versions alive; multiple versions maintain karne padte hain
Bare metalHighest performance; most expensive upfront + setup/maintenance
IaaSHardware+OS provider ka; 8-core/32GB → 8 VMs of 1 core/4 GB; DigitalOcean, AWS, Linode; cheaper, no maintenance; shared → performance suffer
PaaSSoftware layer bhi provider ka; Heroku, Google App Engine; very easy to deploy; lack of control
DropletDigitalOcean ka VM
ProcfileHeroku ko batata hai app kaise run karni hai
requirements.txtPackages + version numbers ki list, jo Heroku install karta hai
gunicornWSGI — Heroku Python apps deploy karne ke liye use karta hai
CI processcommit → CI pull → build+test → ready to deploy → deploy server pull → build,test,deploy → notify complete
CI serversJenkins, CruiseControl
Build toolsAnt, Gradle (Java), Builder (Node.js)
Broken buildTurant fix; last-known good build pe rollback
CI drawbackInitial setup effort
CachingMemcached, Redis; levels — browser, web server page cache, DB query cache
Task queueAsynchronous, HTTP request-response cycle ke bahar; queue of jobs + pool of workers
MinifySpaces/tabs hatao (~41% saving example); Compress = Brotli, Gzip
NumbersAliExpress 30% faster → +10.5% orders; Google 0.5s slower → −25% requests
LighthouseReport generating tool — performance score, SEO, accessibility
Behaviour metricsClickstream, dwell/think time, abandonment
AnalyticsHar page mein JS tracking code embed; e.g. Google Analytics
A/B testingCanary deployment se A aur B chalao, metrics compare karo
09

Assignment-style Practice Questions

Neeche 24 questions hain, IITM graded assignment ke pattern mein (MCQ + MSQ). Option pe click karo → turant sahi/galat + explanation. Sab lecture content se hi bane hain.

Attempted: 0 / 24Correct: 0
10

Last-minute traps

Trap 1

CI server ≠ Build tool. Jenkins/CruiseControl = CI servers. Ant/Gradle/Builder = build tools.

Trap 2

Testing env ≠ Staging env. Integration/system testing → testing env. Performance/stress testing aur feature preview → staging env.

Trap 3

IaaS ≠ PaaS. DigitalOcean/AWS/Linode = IaaS. Heroku/Google App Engine = PaaS. PaaS web server aur DB bhi khud set karta hai.

Trap 4

Minify ≠ Compress. Minify = whitespace/tabs hatana. Compress = Gzip/Brotli se file compress karna. Dono alag steps hain.

Trap 5

Canary ka drawback = multiple instances. Versioned ka drawback = multiple versions. Wording dhyaan se padhna.

Trap 6

Blue/Green ka poochha jaye "biggest advantage" → hamesha easy rollback.