Lesson 06 � Intermediate
CLOUD PAR
DEPLOY KARO.
AI applications ko internet pe deploy karna seekho � AWS, GCP, Azure jaise platforms se serverless aur container-based deployment.
Cloud Deployment kya hai?
Cloud deployment ka matlab hai apne AI applications ko internet pe deploy karna taaki duniya bhar ke log use kar sakein. Aapko apna server khareedne ki zaroorat nahi � AWS, GCP, Azure jaise providers sab kuch manage karte hain.
Cloud deployment mein aapka application internet pe running hota hai, kisi bhi device se access kar sakte ho. Servers, storage, networking sab provider handle karta hai.
Jab aapko apne AI models ya applications ko production mein deploy karna ho, ya scaling ki zaroorat ho.
Startups se lekar enterprise companies tak, sab cloud use karte hain for deployment.
Major Cloud Platforms
Duniya ka sabse bada cloud platform. Lambda, EC2, S3, SageMaker jaise services. AI/ML ke liye bahut powerful tools available hain.
Google ka cloud platform. Cloud Run, Vertex AI, BigQuery. TensorFlow aur ML services ke liye best choice.
Microsoft ka cloud platform. Azure Functions, Azure ML, Cognitive Services. Enterprise companies ke liye popular choice.
Server manage karne ki zaroorat nahi. Aap sirf code likho, baaki scaling, deployment sab auto hota hai. Cost sirf use ke time lagta hai.
Platform Comparison
Feature AWS GCP Azure
-----------------------------------------------------------------
Serverless Lambda Cloud Run / Functions Azure Functions
Container ECS / EKS GKE AKS
AI/ML Platform SageMaker Vertex AI Azure ML
Free Tier 12 months $300 credit $200 credit
Best For All-round Data/ML heavy .NET / EnterpriseAWS Lambda � Serverless Deployment
AWS Lambda ek serverless compute service hai. Aap sirf function likhte ho, AWS baaki sab handle karta hai � servers, scaling, patches sab.
import json
def lambda_handler(event, context):
"""AWS Lambda entry point"""
body = json.loads(event['body'])
text = body.get('text', '')
# Simple sentiment analysis
positive_words = ["good", "great", "awesome", "love", "happy"]
negative_words = ["bad", "hate", "sad", "terrible", "worst"]
text_lower = text.lower()
pos_count = sum(1 for w in positive_words if w in text_lower)
neg_count = sum(1 for w in negative_words if w in text_lower)
if pos_count > neg_count:
sentiment = "positive"
elif neg_count > pos_count:
sentiment = "negative"
else:
sentiment = "neutral"
confidence = min(0.95, 0.6 + (abs(pos_count - neg_count) * 0.1))
return {
'statusCode': 200,
'headers': {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
'body': json.dumps({
'sentiment': sentiment,
'confidence': round(confidence, 2),
'text_analyzed': text[:100]
})
}GCP Cloud Run � Container-based Deployment
Cloud Run aapke Docker containers ko serverless tarike se run karta hai. Koi bhi language, koi bhi framework � sabkaam karta hai.
# Step 1: Dockerfile banao
cat > Dockerfile <Azure Functions � Microsoft ka Serverless
Azure Functions bhi Lambda jaisa serverless hai. Agar aap .NET ya Microsoft ecosystem use karte ho toh ye best choice hai.
import azure.functions as func
import json
app = func.FunctionApp()
@app.route(route="analyze", methods=["POST"])
def analyze_text(req: func.HttpRequest) -> func.HttpResponse:
"""Azure Function for text analysis"""
try:
body = req.get_json()
text = body.get('text', '')
# Word count and basic analysis
words = text.split()
word_count = len(words)
# Sentiment check
positive = ["good", "great", "love", "amazing"]
neg_count = sum(1 for w in text.lower().split() if w in ["bad", "hate", "terrible"])
pos_count = sum(1 for w in text.lower().split() if w in positive)
result = {
'word_count': word_count,
'sentiment': 'positive' if pos_count > neg_count else 'negative' if neg_count > pos_count else 'neutral',
'status': 'success'
}
return func.HttpResponse(
json.dumps(result),
mimetype="application/json",
status_code=200
)
except Exception as e:
return func.HttpResponse(
json.dumps({'error': str(e)}),
mimetype="application/json",
status_code=400
)# Azure Functions deploy
func azure functionapp publish
# Ya Azure CLI se
az functionapp deployment source config-zip \
--resource-group myRG \
--name myFunctionApp \
--src function-app.zip Deployment Steps � Kaise Deploy Karein?
Code Prepare Karo � Apna code clean karo, requirements.txt banao, environment variables set karo. Docker image banao agar container deploy kar rahe ho.
Platform Choose Karo � AWS Lambda (serverless), Cloud Run (containers), ya Azure Functions (Microsoft ecosystem) � jo aapke use case ke liye best ho.
Deploy Karo � CLI commands ya console se deploy karo. Environment variables, API keys, sab set karo. Test karo ki sab kaam kar raha hai.
Monitor & Scale � Logs check karo, errors fix karo, performance monitor karo. Auto-scaling enable karo traffic handle karne ke liye.
Cost Estimation
- AWS Lambda: 1 million requests/month free (12 months)
- GCP Cloud Run: 2 million requests/month free always
- Azure Functions: 1 million requests/month free (always free)
Feature AWS Lambda Cloud Run Azure Functions
-------------------------------------------------------------
Per 1M requests $0.20 $0.40 $0.20
Per GB-second $0.0000166 $0.0000240 $0.0000160
Free tier 400K GB-sec 180K GB-sec 400K GB-secPractice Exercise
Quick check
AWS Lambda kya hai✓ Iska basic definition do.
Sochlo: server +less = server manage nahi karna. Code run karna hai bus.
Ab MLOps par chalo � jahan aap seekhoge ML models ko production mein kaise manage karte hain.