Cloudsviewer
  • Home
  • Google Cloud
  • AWS Amazon
  • Azure
No Result
View All Result
  • Home
  • Google Cloud
  • AWS Amazon
  • Azure
No Result
View All Result
cloudsviewer.com
No Result
View All Result
Home Google Cloud

Optimize, secure and scale your cross-product database operations

April 17, 2023
Optimize, secure and scale your cross-product database operations
Share on FacebookShare on Twitter


This time, you need to see considerably fewer new connections. You may depend them once more with `wc -l`. We now have our proof that establishing a database connection within the world scope is extra environment friendly than doing it within the operate scope.

We famous earlier that growing the variety of concurrent requests for a Cloud Perform may help alleviate the database connections difficulty. Let’s broaden a bit extra on this.

Concurrency with Cloud Capabilities 2nd gen and Cloud Run

By default, Cloud Capabilities can solely course of one request at a time. Nonetheless, Cloud Capabilities 2nd gen are executed in a Cloud Run container. Amongst different advantages, this enables us to configure our features to deal with a number of concurrent requests. Rising the concurrency capability brings Cloud Capabilities nearer to a manner conventional server functions talk with a database. 

In case your operate occasion helps concurrent requests, you can too reap the benefits of connection pooling. As a reminder, the MongoDB driver you’re utilizing will mechanically create and preserve a pool with connections that concurrent requests will use.

Relying on the use case and the quantity of labor your features are anticipated to do, you possibly can regulate:

  • The concurrency settings of your features.

  • The utmost variety of operate situations that may be created.

  • The utmost variety of connections within the pool maintained by the MongoDB driver.

And as we proved, you need to all the time declare your database connection within the world scope to persist it between invocations.

Make your database operations idempotent in event-driven features

You may allow retrying to your event-driven features. Should you do this, Cloud Capabilities will strive executing your operate repeatedly till it completes efficiently or the retry interval ends. 

This performance could be helpful in lots of circumstances, specifically when coping with intermittent failures. Nonetheless, in case your operate incorporates a database operation, executing it greater than as soon as can create duplicate paperwork or different undesired outcomes. 

Let’s contemplate the next instance: The operate store-message-and-notify is executed each time a message is printed to a specified Pub/Sub subject. The operate saves the obtained message as a doc in MongoDB Atlas after which makes use of a third-party service to ship an SMS. Nonetheless, the SMS service supplier regularly fails and the operate throws an error. We now have enabled retries, so Cloud Capabilities tries executing our operate once more. If we weren’t cautious with the implementation, we may duplicate the message in our database.

How can we deal with such eventualities? How can we make our features protected to retry? We now have to make sure that the operate is idempotent. Idempotent features produce precisely the identical outcome no matter whether or not they had been executed as soon as or a number of occasions. If we insert a database doc and not using a uniqueness test, we make the operate non-idempotent.

Let’s give this situation a strive.

Creating the event-driven non-idempotent Cloud Perform

Go to Cloud Capabilities and begin configuring a brand new operate:

Then, click on on Add Eventarc Set off and choose the next within the opened dialog:

Broaden Choose a Cloud Pub/Sub subject after which click on Create a subject. Enter test-topic for the subject ID, after which Create subject.

Lastly, allow Retry on failure and click on Save set off. Notice that the operate will all the time retry on failure even when the failure is attributable to a bug within the implementation.

Add a brand new setting variable referred to as ATLAS_URI along with your connection string and click on Subsequent. 

Exchange the `package deal.json` with the one we used earlier after which, exchange the `index.js` file with the next implementation:



Source link

Guest

Guest

Next Post
What’s new in Azure Data & AI: Azure is built for generative AI apps | Azure Blog and Updates

Inside Azure for IT: 3 cloud strategies to navigate market uncertainty | Azure Blog and Updates

Recommended.

Five Behaviors for Digital Diffusion in EMEA

Achieving data governance for financial services

September 5, 2022
Advancing reliability through a resilient cloud supply chain | Azure Blog and Updates

Microsoft named as a Leader in 2021 Gartner® Magic Quadrant™ for Enterprise Integration Platform as a Service | Azure Blog and Updates

October 9, 2021

Trending.

Complete list of Google Cloud blog links 2021

Complete list of Google Cloud blog links 2021

April 18, 2021
Google Cloud Celebrates International Women’s Day

Google Cloud Celebrates International Women’s Day

March 9, 2021
New – Fully Serverless Batch Computing with AWS Batch Support for AWS Fargate

Goodbye Microsoft SQL Server, Hello Babelfish

November 1, 2021
3 ETFs Perfect for Robinhood Investors

3 ETFs Perfect for Robinhood Investors

October 11, 2020
File Access Auditing Is Now Available for Amazon FSx for Windows File Server

File Access Auditing Is Now Available for Amazon FSx for Windows File Server

June 13, 2021
  • Advertise
  • Privacy & Policy

© 2022 Cloudsviewer - Cloud computing news. Quick and easy.

No Result
View All Result
  • Home

© 2022 Cloudsviewer - Cloud computing news. Quick and easy.