How SafetyCulture scales unpredictable dbt Cloud workloads in a cheap means with Amazon Redshift

This put up is co-written by means of Anish Moorjani, Information Engineer at SafetyCulture.

SafetyCulture is a world generation corporate that places the ability of constant growth into everybody’s arms. Its operations platform unlocks the ability of remark at scale, giving leaders visibility and employees a voice in using high quality, potency, and protection enhancements.

Amazon Redshift is an absolutely controlled information warehouse provider that tens of hundreds of consumers use to control analytics at scale. In conjunction with price-performance, Amazon Redshift allows you to use your information to procure new insights for what you are promoting and consumers whilst holding prices low.

On this put up, we proportion the answer SafetyCulture used to scale unpredictable dbt Cloud workloads in a cheap means with Amazon Redshift.

Use case

SafetyCulture runs an Amazon Redshift provisioned cluster to fortify unpredictable and predictable workloads. A supply of unpredictable workloads is dbt Cloud, which SafetyCulture makes use of to control information transformations within the type of fashions. On every occasion fashions are created or changed, a dbt Cloud CI task is brought about to check the fashions by means of materializing the fashions in Amazon Redshift. To steadiness the wishes of unpredictable and predictable workloads, SafetyCulture used Amazon Redshift workload control (WLM) to flexibly set up workload priorities.

With plans for additional expansion in dbt Cloud workloads, SafetyCulture wanted an answer that does the next:

  • Caters for unpredictable workloads in a cheap means
  • Separates unpredictable workloads from predictable workloads to scale compute sources independently
  • Continues to permit fashions to be created and changed in line with manufacturing information

Resolution assessment

The answer SafetyCulture used is made from Amazon Redshift Serverless and Amazon Redshift Information Sharing, at the side of the present Amazon Redshift provisioned cluster.

Amazon Redshift Serverless caters to unpredictable workloads in a cheap means as a result of compute value isn’t incurred when there’s no workload. You pay just for what you utilize. As well as, shifting unpredictable workloads right into a separate Amazon Redshift information warehouse permits each and every Amazon Redshift information warehouse to scale sources independently.

Amazon Redshift Information Sharing allows information get admission to throughout Amazon Redshift information warehouses with no need to duplicate or transfer information. Subsequently, when a workload is moved from one Amazon Redshift information warehouse to every other, the workload can proceed to get admission to information within the preliminary Amazon Redshift information warehouse.

The next determine presentations the answer and workflow steps:

  1. We create a serverless example to cater for unpredictable workloads. Check with Managing Amazon Redshift Serverless the usage of the console for setup steps.
  2. We create a datashare referred to as prod_datashare to permit the serverless example get admission to to information within the provisioned cluster. Check with Getting began information sharing the usage of the console for setup steps. Database names are similar to permit queries with complete trail notation database_name.schema_name.object_name to run seamlessly in each information warehouses.
  3. dbt Cloud connects to the serverless example and fashions, created or changed, are examined by means of being materialized within the default database dev, in both each and every customers’ private schema or a pull request comparable schema. As an alternative of dev, you’ll use a special database designated for checking out. Check with Attach dbt Cloud to Redshift for setup steps.
  4. You’ll question materialized fashions within the serverless example with materialized fashions within the provisioned cluster to validate adjustments. After you validate the adjustments, you’ll enforce fashions within the serverless example within the provisioned cluster.

End result

SafetyCulture performed the stairs to create the serverless example and datashare, with integration to dbt Cloud, comfortably. SafetyCulture additionally effectively ran its dbt undertaking with all seeds, fashions, and snapshots materialized into the serverless example by the use of run instructions from the dbt Cloud IDE and dbt Cloud CI jobs.

Referring to functionality, SafetyCulture noticed dbt Cloud workloads finishing on reasonable 60% sooner within the serverless example. Higher functionality might be attributed to 2 spaces:

  • Amazon Redshift Serverless measures compute capability the usage of Redshift Processing Devices (RPUs). As it prices the similar to run 64 RPUs in 10 mins and 128 RPUs in 5 mins, having a better collection of RPUs to finish a workload faster was once most well-liked.
  • With dbt Cloud workloads remoted at the serverless example, dbt Cloud was once configured with extra threads to permit materialization of extra fashions immediately.

To decide value, you’ll carry out an estimation. 128 RPUs supplies roughly an identical quantity of reminiscence that an ra3.4xlarge 21-node provisioned cluster supplies. In US East (N. Virginia), the price of operating a serverless example with 128 RPUs is $48 hourly ($0.375 consistent with RPU hour * 128 RPUs). In the similar Area, the price of operating an ra3.4xlarge 21-node provisioned cluster on call for is $68.46 hourly ($3.26 consistent with node hour * 21 nodes). Subsequently, an accrued hour of unpredictable workloads on a serverless example is 29% more cost effective than an on-demand provisioned cluster. Calculations on this instance will have to be recalculated when acting long run value estimations as a result of costs would possibly exchange through the years.


SafetyCulture had two key learnings to higher combine dbt with Amazon Redshift, which may also be useful for an identical implementations.

First, when integrating dbt with an Amazon Redshift datashare, configure INCLUDENEW=True to ease control of database gadgets in a schema:


As an example, suppose the style consumers.sql is materialized by means of dbt because the view consumers. Subsequent, consumers is added to a datashare. When consumers.sql is changed and rematerialized by means of dbt, dbt creates a brand new view with a short lived identify, drops consumers, and renames the brand new view to consumers. Even if the brand new view carries the similar identify, it’s a brand new database object that wasn’t added to the datashare. Subsequently, consumers is now not discovered within the datashare.

Configuring INCLUDENEW=True permits new database gadgets to be routinely added to the datashare. A substitute for configuring INCLUDENEW=True and offering extra granular keep watch over is using dbt post-hook.

2nd, when integrating dbt with a couple of Amazon Redshift information warehouse, outline resources with database to help dbt in comparing the correct database.

As an example, suppose a dbt undertaking is used throughout two dbt Cloud environments to isolate manufacturing and take a look at workloads. The dbt Cloud atmosphere for manufacturing workloads is configured with the default database prod_db and connects to a provisioned cluster. The dbt Cloud atmosphere for take a look at workloads is configured with the default database dev and connects to a serverless example. As well as, the provisioned cluster accommodates the desk prod_db.raw_data.gross sales, which is made to be had to the serverless example by the use of a datashare as prod_db′.raw_data.gross sales.

When dbt compiles a style containing the supply {{ supply('raw_data', 'gross sales') }}, the supply is evaluated as database.raw_data.gross sales. If database isn’t outlined for resources, dbt units the database to the configured atmosphere’s default database. Subsequently, the dbt Cloud atmosphere connecting to the provisioned cluster evaluates the supply as prod_db.raw_data.gross sales, whilst the dbt Cloud atmosphere connecting to the serverless example evaluates the supply as dev.raw_data.gross sales, which is improper.

Defining database for resources permits dbt to constantly overview the correct database throughout other dbt Cloud environments, as it gets rid of ambiguity.


After checking out Amazon Redshift Serverless and Information Sharing, SafetyCulture is glad with the outcome and has began productionalizing the answer.

“The PoC confirmed the huge attainable of Redshift Serverless in our infrastructure,” says Thiago Baldim, Information Engineer Staff Lead at SafetyCulture. “Shall we migrate our pipelines to fortify Redshift Serverless with easy adjustments to the factors we have been the usage of in our dbt. The end result supplied a transparent image of the prospective implementations lets do, decoupling the workload totally by means of groups and customers and offering the correct degree of computation energy this is speedy and dependable.”

Even if this put up in particular objectives unpredictable workloads from dbt Cloud, the answer could also be related for different unpredictable workloads, together with advert hoc queries from dashboards. Get started exploring Amazon Redshift Serverless in your unpredictable workloads nowadays.

In regards to the authors

Anish Moorjani is a Information Engineer within the Information and Analytics workforce at SafetyCulture. He is helping SafetyCulture’s analytics infrastructure scale with the exponential building up within the quantity and number of information.

Randy Chng is an Analytics Answers Architect at Amazon Internet Products and services. He works with consumers to boost up the answer in their key industry issues.

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: