0
0
GCPcloud~20 mins

Real-time updates with listeners in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Real-time Updates Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
How does a Firestore listener behave on document update?

You set up a Firestore listener on a document to get real-time updates. What happens when the document is updated?

AThe listener triggers only if the document is deleted, not on updates.
BThe listener triggers only once when first attached and never again.
CThe listener triggers only if the document is created, not on updates.
DThe listener triggers once immediately and then again every time the document changes.
Attempts:
2 left
💡 Hint

Think about how real-time updates work in Firestore listeners.

Architecture
intermediate
2:00remaining
Best architecture for real-time updates with Cloud Pub/Sub

You want to build a system that sends real-time updates from a backend to multiple clients. Which architecture best supports this using Cloud Pub/Sub?

ABackend publishes messages to a Pub/Sub topic; clients subscribe directly to the topic to receive updates.
BClients publish messages to a Pub/Sub topic; backend subscribes to process updates.
CBackend writes updates to Cloud Storage; clients poll the storage for changes.
DBackend sends HTTP requests directly to clients without Pub/Sub.
Attempts:
2 left
💡 Hint

Consider how Pub/Sub supports message distribution to multiple subscribers.

security
advanced
2:00remaining
Securing Firestore listeners for real-time updates

You want to ensure only authorized users receive real-time updates from Firestore listeners. Which method best enforces this?

AEncrypt data on the client side before sending it to Firestore.
BUse Firestore security rules to restrict read access based on user authentication and document fields.
CDisable Firestore listeners and use polling instead.
DUse a VPN to restrict network access to Firestore.
Attempts:
2 left
💡 Hint

Think about how Firestore controls access to data.

Configuration
advanced
2:00remaining
Configuring Cloud Functions to trigger on Firestore updates

Which Cloud Function trigger configuration correctly listens to document updates in Firestore?

Afunctions.firestore.document('collection/{docId}').onDelete((snap, context) => { ... })
Bfunctions.firestore.document('collection/{docId}').onCreate((snap, context) => { ... })
Cfunctions.firestore.document('collection/{docId}').onUpdate((change, context) => { ... })
Dfunctions.pubsub.topic('topicName').onPublish((message) => { ... })
Attempts:
2 left
💡 Hint

Focus on the trigger that responds to document updates.

Best Practice
expert
2:00remaining
Optimizing Firestore listeners for cost and performance

You have many clients listening to Firestore documents for real-time updates. What is the best practice to reduce costs and improve performance?

AUse collection group queries with listeners to reduce the number of listeners needed.
BUse polling every few seconds instead of listeners to reduce Firestore reads.
CSet up a listener on each individual document separately for precise updates.
DDisable offline persistence on clients to reduce local storage usage.
Attempts:
2 left
💡 Hint

Think about how to minimize the number of active listeners.