0
0
Microservicessystem_design~10 mins

Independent service pipelines in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a microservice that listens to its own message queue.

Microservices
def start_service():
    queue = get_message_queue('[1]')
    while True:
        message = queue.receive()
        process_message(message)
Drag options to blanks, or click blank then click option'
Acommon_queue
Bshared_queue
Cglobal_queue
Dindependent_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a shared queue causes message processing conflicts.
Using a global queue breaks service independence.
2fill in blank
medium

Complete the code to deploy each microservice pipeline independently using containers.

Microservices
def deploy_pipeline(service_name):
    container = create_container(image=service_name)
    container.[1]()
Drag options to blanks, or click blank then click option'
Astop
Bstart
Cpause
Drestart
Attempts:
3 left
💡 Hint
Common Mistakes
Using stop instead of start prevents the service from running.
Restart is invalid before the container is started.
3fill in blank
hard

Fix the error in the code to ensure each microservice pipeline scales independently.

Microservices
def scale_service(service, replicas):
    if replicas < 1:
        raise ValueError('Replicas must be at least [1]')
    service.set_replicas(replicas)
Drag options to blanks, or click blank then click option'
A0
B2
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Allowing zero replicas causes the service to stop.
Setting replicas less than one causes runtime errors.
4fill in blank
hard

Fill both blanks to configure independent pipelines with separate databases and APIs.

Microservices
pipeline_config = {
    'database': '[1]',
    'api_endpoint': '[2]'
}
Drag options to blanks, or click blank then click option'
Auser_db
Bshared_db
C/user/api
D/common/api
Attempts:
3 left
💡 Hint
Common Mistakes
Using shared_db breaks data isolation.
Using common API endpoints causes routing conflicts.
5fill in blank
hard

Fill all three blanks to implement independent logging, monitoring, and alerting for each pipeline.

Microservices
def setup_pipeline_monitoring(pipeline):
    pipeline.logger = Logger('[1]')
    pipeline.monitor = Monitor('[2]')
    pipeline.alert_system = AlertSystem('[3]')
Drag options to blanks, or click blank then click option'
Apipeline_logs
Bpipeline_metrics
Cpipeline_alerts
Dshared_logs
Attempts:
3 left
💡 Hint
Common Mistakes
Using shared_logs mixes logs from different pipelines.
Not configuring alerts per pipeline delays issue detection.