<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Deepak Sethi on Medium]]></title>
        <description><![CDATA[Stories by Deepak Sethi on Medium]]></description>
        <link>https://medium.com/@deepaksethi.ocp?source=rss-d67e34064be7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QxOkLTJncN6DRb63</url>
            <title>Stories by Deepak Sethi on Medium</title>
            <link>https://medium.com/@deepaksethi.ocp?source=rss-d67e34064be7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:07:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deepaksethi.ocp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Matillion with AWS Redshift]]></title>
            <link>https://medium.com/@deepaksethi.ocp/matillion-with-aws-redshift-90363a5e7aa?source=rss-d67e34064be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/90363a5e7aa</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[matillion]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[matillionawsredshift]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <dc:creator><![CDATA[Deepak Sethi]]></dc:creator>
            <pubDate>Thu, 12 Sep 2019 09:25:10 GMT</pubDate>
            <atom:updated>2019-09-12T09:25:10.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Data Lake?</h3><p>Data Lake is a way to store huge volumes of data in a low cost storage medium. Stored data can be structured or non-structured in untransformed form. A Data Lake can have data from more than one sources and stores it in natural raw form. Data stored in Data lakes can be accessed by data scientists, analysts, developers to perform various analysis, apply machine learnings to derive best value from the data.</p><h3>Implementation of Data Lake</h3><p>As described above that Data Lake has data from various sources which can be in any format like database, csv, JSON and flat file. In order to get the data from external sources, load them into data warehouse and Data Lake, then apply transformations for which we need tools as described below:</p><h3>· ELT/ETL Tool and Integrations</h3><p>ELT/ETL tools are used to connect various sources in variety of formats like OLTP database, source files, or any API etc. These tools can extract and transform them in a unified format in data warehouse so that they can used for analytics and business intelligence. Matillion is one of the popular cloud ELT platforms with capability to connect major data warehouse vendors like AWS and Google.</p><h3>· Cloud Data Warehouse</h3><p>Cloud data warehouse is database service in cloud with powerful features like massively parallel processing, columnar data storage, data compression, scalability, unmatched storage and computing power as compared to an on premise data warehouse. For e.g. AWS Redshift, Google BigQuery</p><h3>· BI Tools and Reporting Tools</h3><p>BI tools are used to process the raw data, formulate into graphs, dashboards, charts, reports or any pictorial representation etc. and get meaningful insights for the organization. Few examples for BI Tools are AWS QuickSight, IBM Cognos and Reporting tools are Tableau, TIBCO etc.</p><h3>What is Matillion?</h3><p>Matillion is an <strong>ELT tool</strong> in cloud to connect cloud data warehouses. It’s a web based ELT tool and we can easily create jobs by drag and drop features of Matillion. Matillion has a capability to connect variety of sources like database, files with different formats from on-premise or on-cloud. Matillion stages data in AWS Simple Storage Service (S3) before loading data into AWS Redshift warehouse.</p><p>Matillion is available in 3 flavors:</p><h3>· Matillion for AWS Redshift</h3><h3>· Matillion for <a href="https://www.matillion.com/etl-for-snowflake/">Snowflake</a></h3><h3>· Matillion for Google <a href="https://www.matillion.com/etl-for-bigquery/">BigQuery</a></h3><h3>What is ELT and how is it different from ETL terminology?</h3><p>ELT (Extract, Load, and Transform) –This is a new emerging process. In the first step entire raw data from any source/sources is loaded into a <em>stage area</em>. Then transformations (formula, aggregations etc.) can be applied on raw data. ELT is beneficial when target data warehouse is well capable to perform heavy transformations. <strong>For e.g. AWS Redshift.</strong> This is very economical and faster when data warehouse is mounted on the cloud where cost is charged with each data request. Once data is loaded into Stage area of data warehouse it can achieve following benefits</p><p>· Any number of queries, transformations can be performed on stage data with minimal cost</p><p>· Operations on data is faster because data is already on the cloud and queries on data warehouse on cloud are faster than traditional on-premises data warehouses.</p><p>· In case of unavailability of data source, stage data can be used without bothering about the source systems availability.</p><p>On the other side, ETL stand for Extract, Transform, and Load. ETL is a set of processes which extracts the data from various sources, applies transformations and then loads into target data warehouse.</p><h3>What is AWS Redshift?</h3><p>AWS Redshift is a data warehouse service available on cloud. AWS Redshift is petabyte scale, powerful and fully managed relational data warehousing service. AWS Redshift can connect with client applications with JDBC, ODBC connections. It’s based on PostgreSQL standard. AWS Redshift provides efficient storage and faster query performance through it’s unique properties like massively parallel processing, columnar data storage, and various data compression encoding schemes.</p><p>For more context on <a href="https://www.matillion.com/etl-for-redshift/">AWS Redshift</a> use my another article on <a href="https://medium.com/@deepaksethi.ocp/aws-redshift-whitepaper-84e013272841">Medium</a>:</p><h3>How to install Matillion on EC2?</h3><p>Matillion is available on AWS marketplace and can be download using AWS account. Matillion can be setup easily on AWS EC2 instance quickly with small and easy set of steps like use Amazon machine Image (64 bit), setup AWS EC2 instance (based on the need) followed by setting up a role with permissions. Permissions can be of various AWS services which we want to use through Matillion components. <em>Cost for Matillion is monitored and billed via AWS account.</em></p><p>Matillion can be easily integrated with SQS, SNS, S3, AWS Redshift etc. using AWS APIs. Once Matillion is setup its ready create, manager, schedule, and run jobs.</p><p>A Matillion instance is set of multiple groups, group has multiple projects. Project can have folders in it to keep logical categorization of jobs, type of jobs with their action, subject area, or dependent jobs technically or functionally.</p><p>A Job in Matillion is a set of components or any other jobs connected with each other, to perform a specified set of steps defined in the job’s workflow. Job can have input from various sources and can load data into database, or any file system like S3.</p><h3>Matillion Features and Capabilities</h3><p>Matillion is rich with various features and capabilities which makes it a good solution for new era databases on cloud with columnar, MPP like features. Matillion and AWS Redshift together build a solution which make a faster, easy solution to build a Data lake. Here are few of the features explained:-</p><h3>· Data Sources</h3><p>Matillion supports connectivity with numerous external sources like Amazon S3, RDS, Excel, CSV, JSON, Salesforce, Databases, APIs, Social media. Matillion for AWS Redshift has support for many services through corresponding component like AWS cloud watch, AWS SNS, AWS SQS etc.</p><h3>· Scheduling</h3><p>Jobs in Matillion can run manually or automatically in scheduled fashion. To run a job manually, right click the job and run. To run it automatically, you can schedule based on need. You can schedule the job on specified time, interval (Daily, weekly etc.) from “Project è Manager Schedule”</p><h3>· Task History and Job Monitoring</h3><p>Task history for every job is maintained in Matillion. We can look the get information about historic run from Project menu. We can monitor the job from task panel. When jobs are running on schedule and no one is back in office to monitor alerts can be sent through SNS if job is failed.</p><h3>· Shared jobs</h3><p>Jobs which perform common set of operation can be saved as shared jobs in Matillion. They can be reused as common component in the project to avoid redundancy of the code, components.</p><h3>· Replay/Reprocessing</h3><p>Reprocessing of the records can be implemented using incremental runs based on last load. Reprocessing of the records is done very fast as Matillion uses stage copy of data. In case of failure entire transaction is failed and when re-run it ensure not duplicate records or missing records are there.</p><h3>· Dependency Management</h3><p>Manage dependency for cases like late arriving dimensions with components like unite, and left outer join etc.</p><h3>· Change Data Capture</h3><p>Matillion provides the feature to detect Change data capture using its component named as <em>“Change Detect”</em>. This feature helps to determine the changes in the source from previous runs. Matillion uses S3 buckets to record those changes.</p><h3>· Backup and Restore Migration of Resources</h3><p>Export/Import allows to take backup of variables, jobs and environments details. Exported resources saved in JSON format. They can be easily migrated from one Matillion instances to another or can be used as backup helpful for restoration.</p><h3>· Migration of Resources</h3><p>Migrate helps to migrate resources from one environment to another environment directly into the target environment. It’s easier as compared to export/import functionality. Migrating a resource essentially clones it to the target instance. Target Matillion ETL instance must allow incoming TCP/IP connections from the source Matillion ETL instance. Migrate can migrate more resource than export/import functionality like jobs, variables, environments, schedules, credentials, shared jobs, versions, projects and project groups etc.</p><h3>How to implement a Matillion job to load data into AWS Redshift?</h3><h3>Scenario</h3><p>· Setup a job in Matillion to extract data from Oracle OLTP database, SQL server and data files available on AWS S3.</p><p>· Apply common components like Exception Handling, Audit and Logging</p><p>· Archive inactive/infrequently access data on AWS S3</p><h3>Architecture diagram:-</h3><p>Following diagram explains the architecture and flow of data through various stages. Load data from external sources using Matillion to AWS Redshift, archival of historical data on S3. Apply business intelligence and reporting using tools like AWS QuickSight and Tableau respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*YvVOxME-LpuR-zFKsiMtxg.png" /></figure><p>In following section, we will describe how to create, run and monitor jobs in Matillion:-</p><p>Once Matillion <a href="https://redshift-support.matillion.com/s/article/2487672">setup</a> is done with AWS Redshift, we can start developing jobs in Matillion</p><p>· First step for ELT jobs is to interact with <em>external sources </em>like S3, Oracle, SQL Server, and many more. Matillion provides <em>Orchestration Jobs </em>which has capability to connect with data sources easily using components like Database query component, S3 load etc.</p><h3>Extraction and Loading of data</h3><p>· In Orchestration jobs, in order to extract data from database sources, like Oracle, SQL Server, MySQL, PostgreSQL a <em>Data Query </em>component can used. It require JDBC driver, connection URL to connect AWS Redshift, DB credentials, SQL query, Table name <em>Load options</em> parameters to communicate with supported databases. A new table is created with given name in “Table Name” parameter. <em>Load option manages if table need to be recreated with every run or not. </em>Extracted data can be of Pricing, Accounting, Risk exposure etc.</p><p>· <em>To load data from non-database source sources/files</em> with formats like JSON, CSV available on AWS simple storage service, S3 load component is available. <em>S3 Load</em> component works accept few parameters and work fast to load huge amount of data in seconds. S3 load component need data file, layout file in JSON format which explains the structure of the data file, target table where data need to be loaded</p><h3>Transformation</h3><p>· Once data is loaded into stage area, it requires manipulations, transformation, aggregations, calculations, and populate the transformed data into final table like dimension, fact tables. Matillion provides <em>Transformation jobs</em> and components to perform data level operations using available rich components like SQL component, Unite component, calculator component, table input, table output and table update components etc. Transformation examples could be merging columns values, aggregating values to get average price of any crude oil, highest sold products in a month, counterparties with highest exposures values in a month etc.</p><p>o Table output and Table updated components are used in Transformation jobs to load data into Target table. Load type (Append/Truncate), (Insert/Delete, Insert/Update) is factor to decide which component to be used in the final table</p><p>o <strong>For e.g.</strong> Historical tables never truncates so we used Table Output component with Append option</p><p>o Table Update component used Fact tables to load data incrementally based on unique key</p><p>· To call a Matillion job from another job i.e. Orchestration or Transformation, Matillion provides <em>Run Transformation Job</em> and <em>Run orchestration Job</em> components. With this feature we can make jobs dependent and nested.</p><h3>Run Jobs in Matillion</h3><p>Jobs can be run manually, can be scheduled or be based on an event</p><p>· Run jobs Manually by right click on the job then <em>“Run Job”</em></p><p>· Jobs can be scheduled from Matillion in quick set of steps from <em>Project è Manage Schedule option</em> using cron job like format</p><p>· Events from S3 can also help to trigger a Matillion job when a new file is added in an S3 bucket. For example we need to trigger a Matillion job when source data files for Intraday and End of day arrives. Based on event Lambda function can be triggered to execute the job</p><h3>Job Monitoring</h3><p>Once jobs are executed successfully, we can monitor the jobs in Matillion.</p><p>· Job monitoring for running jobs can be done from Matillion front end in <strong>Tasks section </strong>on the bottom right section.</p><p>· To monitor or track the status of the job when one is not in front of computer, AWS SNS (Simple Notification Service) topics can be configured to notify with mobile text or Email etc. to share the job status to required teams</p><h3>Common Components/Framework</h3><p>A common framework for logging exception, error handling, and audit details of jobs can be valuable to track the activities happened on the table. This common framework can be used with all jobs for which we need to handle transactions, log exceptions or track the operations performed on the table.</p><p>· Exception handling framework can be implemented using <em>End Success</em> and <em>End Failure</em> components. This can help to locate the failed jobs and can be re-run so that data can be available in the system. Exceptions could be data errors, target table or column does not exist, mismatch of data type, incorrect date format etc. Such issues could lead to fail the job.</p><p>· Running failed jobs may lead to load duplicate or missing some data if we do not track the transactions. Idempotent architecture can be implemented using Matillion’s <em>Begin</em> and <em>End</em> components to track transactions. Idempotent architecture helps to commit or rollback the changes in the job completely. This helps to reprocess the failed jobs accurately, completely and without duplicate or missing records</p><p>· Auditing and logging is also a value ad to track activity done by any job like when last job was executed, how many records inserted etc. Auditing and Logging can be implemented using Matillion attributes which capture metadata of each component like <em>Component, Start At Complete At, Duration, Message, Row count, and Status etc. values of these attributes can be captured in corresponding variables in Export </em>tab of every component. Later, those variable values can be loaded into database tables</p><h3>Archival of Historical/infrequently accessed Data on S3?</h3><p>After a certain point some data can be irrelevant, less accessed by business users. Keeping that data in AWS Redshift may incur additional cost, degrade query performance over the years. To avoid such circumstances, we can unload such Infrequent Accessed Data into Amazon S3. Amazon S3 is low cost storage service to store unlimited data. Matillion provides <em>S3 Unload </em>component to migrate data from AWS Redshift to S3. <strong>For e.g.</strong> At any point of time business wants to keep only 2 year of data as active in AWS Redshift and remaining data to be unloaded into S3</p><p>· Using <em>Query Result to Grid</em> component, we can extract the partitions, keys from database which more than 2 years old and store it in grid variables.</p><p>· Grid iterator can be used to iterate over the grid variables based on partition keys</p><p>· ‘S3 Unload’ components can used to unload historical data into partitions in S3 buckets based on their business area. Each table has different partition key to segregate the data while unloading into S3</p><p>· Loaded data in S3 can be as CSV, or tab delimited format</p><p>· Files can be converted into Parquet format using python scripts to store in AWS S3. Data stored in parquet format is easier to extract, faster to query as well as economical</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90363a5e7aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Redshift WhitePaper]]></title>
            <link>https://medium.com/@deepaksethi.ocp/aws-redshift-whitepaper-84e013272841?source=rss-d67e34064be7------2</link>
            <guid isPermaLink="false">https://medium.com/p/84e013272841</guid>
            <category><![CDATA[columnar-databases]]></category>
            <category><![CDATA[cloud-data-warehouse]]></category>
            <category><![CDATA[aws-redshift]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[redshift]]></category>
            <dc:creator><![CDATA[Deepak Sethi]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 13:12:40 GMT</pubDate>
            <atom:updated>2019-09-04T14:48:04.815Z</atom:updated>
            <content:encoded><![CDATA[<h3>by Deepak Sethi</h3><h3>(4th Sep 2019)</h3><h3>1. Redshift — Overview</h3><p>AWS Redshift is a data warehouse service available on cloud. Redshift is petabyte scale, powerful and fully managed relational data warehousing service. Redshift can connect with client applications with JDBC, ODBC connections. It’s based on PostgreSQL standard.</p><p>Amazon Redshift provides efficient storage and faster query performance through it’s unique properties like massively parallel processing, columnar data storage, and various data compression encoding schemes.</p><p>An Amazon Redshift data warehouse is a collection of computing resources called <em>nodes</em>, which are organized into a group called a <em>cluster</em>. Each cluster runs an Amazon Redshift engine and contains one or more databases.</p><h3>2. Characteristics of Redshift</h3><p>Following are characteristics of AWS Redshift:</p><h3>a. Massively Parallel Processing</h3><p>MPP enables fast execution of complex queries on large amount of data. In Redshift, multiple compute nodes work in parallel and handle all query processing to get final aggregated result. Each node executes the same compiled query segment on portion of data allocated. Redshift distributes the rows of a table to the compute nodes so that the data can be processed in parallel. Internal communication helps to perform parallel processing.</p><h3>b. Columnar Data Storage</h3><p>Columnar data storage is one of the best property of Amazon Redshift. This keeps it ahead with other databases in term of performance and optimized way of storing data into Redshift. Columnar storage for database tables reduces the overall disk I/O requirement. This is an important factor in optimizing analytic query performance. This reduces the amount of data we need to load from disk. Loading less data into memory enables Redshift to perform more in-memory processing when executing queries.</p><h3>c. Data Compression</h3><p>Compression is column level operation which reduces size of data when it stored. Redshift compress the data which reduces the requirement of disk I/O which eventually result into gain query performance. At the time of query execution, compressed data is read into memory, then uncompressed. Loading less data into memory for execution enable Redshift to allocate more memory for analyzing the data. As Redshift uses columnar storage to store similar data sequentially, thus Redshift is able to adaptive compression encoding specifically tied to columnar data types. Best way to apply compression is to allow Redshift to apply optimal compression encoding.</p><h3>d. Query Optimizer</h3><p>Redshift query optimizer implements significant enhancement for processing complex analytic queries on large dataset by taking advantage of MPP and columnar data storage properties. This turns into generate optimized query execution plan to perform fast query execution.</p><h3>e. Result Caching</h3><p>Redshift buffers the result of recent queries into memory of leader node. This avoids to perform parsing (syntax check, Symantec check etc.) and generating the execution plan. This helps to reduce the execution time of the query and improve the query and database performance. When a query is received for execution, Redshift checks if valid match is found in buffer, then that buffered result will be returned to user. It’s enabled by default. Caching can be changed by setting enable_result_cache_for_session parameter to off.</p><h3>f. Compiled Code</h3><p>Leader node distributes optimized compiled code across all available nodes of a cluster. Compiling the query eliminates the overhead associated with an interpreter and therefore increases speed of user queries. Compiled code is buffered and shared across all sessions on the same cluster so the subsequent execution of the same query <em>[with different parameter] </em>will be faster. The execution engine compiles different code for JDBC, ODBC, and PSQL connection protocols. <strong>For e.g.</strong> two clients using different protocol executing same query for first time, will have first time compilation code.</p><h3>3. Redshift Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*Oz5zMzdTH-WnQgWxVusIGQ.png" /></figure><h3>Here are the components of Redshift Architecture</h3><h3>a. Cluster</h3><p>A Cluster in terms of Redshift is set of one or more compute nodes. There are two type of nodes <em>Leader Node</em> and <em>Compute Node </em>described below. If a cluster has two or more compute nodes, and additional leader node is there to coordinate with all compute nodes and external communication with client applications. In case of single compute node, it act as leader as well as compute node. There can be 101 nodes/cluster and 200 reserved nodes.</p><h3>b. Leader node</h3><p>Leader node interacts with client applications and communicates with compute nodes to carry out operations. It parses and generates an execution plan to carry out database operations. Based on execution plan, then it compiles the code. Then compiled code is distributed to all provisioned compute nodes and its data portion to each node.</p><h3>c. Compute nodes</h3><p>Primary responsibility of leader node to compiles code, interaction with external applications and client applications. Leader node compile each step of execution plan and assign that to all compute nodes. Compute nodes carry out execution of the given compiled code and send back intermediate results back to leader node to aggregate the final result for each request from client application.</p><p>Each compute node has its own dedicated CPU, memory and storage which are essentially determined by node type. Based on workload, compute capacity, storage of a cluster can be enhanced by adding either by adding number of nodes, or by upgrading node type or both.</p><p>AWS Redshift provides two node types at high level:</p><p>· Dense storage nodes (ds1 or ds2)</p><p>· Dense compute nodes (dc1 or dc2)</p><p>Max Total tables — 900 [For large and xlarge cluster node types and 20000 for 8xlarge cluster node types]</p><h3>d. Node slices</h3><p>Compute node is further partitioned into slices. Each slice is allocated a portion of node’s memory, disk space where it carries out the given workload to the node. Leader node manages distributing data to slices for any queries or other database operations to the slices. All slices work in parallel to complete the operation. The number of slices are determined by node size of the cluster.</p><h3>e. Internal network</h3><p>Internal network is for communication between leader node and compute nodes to perform various database operations. Redshift has very high-bandwidth connections, various communication protocols to provide high speed, private and secure communication across leader and compute nodes.</p><h3>f. Databases</h3><p>A cluster contains one or more databases. User data is stored on compute nodes. Redshift is a RDBMS, so it is compatible with other RDBMS applications. Although it provides same functionality as typical RDBMS including OLTP functions like DMLs, however it’s optimized for high-performance analysis and reporting on large datasets. Limit of user defined databases 60/cluster and total schemas 9900/cluster</p><h3>g. Connections</h3><p>Redshift interacts with client applications using JDBC and ODBC drivers for Postgre SQL.</p><h3>h. Client applications</h3><p>AWS Redshift provides flexibility to connect with various client tools like ETL, business intelligence reporting, and analytics tools <strong>for e.g. Matillion for Redshift</strong>. It is based on industry standard PostgreSQL most existing SQL client applications are compatible and work with little or without any changes.</p><h3>Redshift Internal Workflow Diagram</h3><p>Following image is more detailed Redshift architecture which elaborates the internal communication between all components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*rHuGkn5dVlV6W-E-e2BYWg.png" /></figure><h3>4. Query Planning and Execution workflow</h3><p>This section explains order of execution of a query:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*ekpj3fEM19n2NJJyTW0Euw.png" /></figure><p>a. Leader node receives the queries from client application. First step of query execution is to parse the query which includes syntax and semantic check of the query.</p><p>b. Once query is parsed, parser generates a query tree which is a logical representation of the received query. This query tree is input for query optimizer.</p><p>c. Query optimizer evaluates and rewrite the query to maximize the efficiency of the query.</p><p>d. Optimizer generates an optimized query execution plan. This plan has join types, join orders, aggregation options and data distribution requirements.</p><p>e. Execution engine translates the query plan into <em>steps, segments and stream</em></p><p><em>Step</em> — Each step is an operation required for query execution. Steps can be combined to allow compute nodes to perform query, join etc.</p><p><em>Segment</em> — A combination of several steps that can be done by a single process, also the smallest compilation unit executable by a compute node slice.</p><p><em>Stream</em> — Collection of segments to be parceled out over the available compute node slices. Execution engine generates the compiled code on steps, segments and streams. Compiled code executes faster than interpreted code and require less capacity</p><h3>5. Other Features</h3><p>Redshift has list of features which help us in our day to day activities. These features can help us gaining productivity, managing workload and security in our Redshift cluster. Few of them can be managed through Redshift parameters groups or from AWS console or carried out manually as and when required.</p><h3>a. Workload Management</h3><p>Redshift provides a feature of workload management this includes manage priorities of the queries to avoid bottleneck in the database. When a query is sent for execution, WLM assigns the query to a queue according to the user’s user group or by matching a query group that is defined in the queue configuration with a query group label that the user sets at runtime.</p><p>Query queues are created at runtime according to service classes, which define the configuration parameters for various types of queues, including internal system queues and user accessible queues.</p><p>As workload is managed by queue, there is a <em>default</em> queue as well as a <em>super user</em> queue associated with a cluster. Any query which is not routed to a queue will be executed with default queue while super user queue is reserved for operations performed by super user.</p><h3>b. Backup and Recovery</h3><p>Backup of the data in Redshift database can be taken by Automatic or Manual backup/Snapshot. Backups can be used to restore the data to a cluster. While data is restored from a snapshot, a new cluster is created with snapshot data.</p><p>We can take or schedule backup from AWS management console. Redshift periodically takes automatic backup incrementally and saves it to Amazon S3. Also, Redshift allows to set snapshot retention period while taking manual backup. Automated snapshots cannot be deleted manually. Snapshots can be replicated to other regions as well. There can be 20 snapshots per cluster.</p><h3>c. Auditing and Logging</h3><p>We can use the database audit and logging feature to track information about number of activities performed against Redshift cluster like authentication attempts, connections, disconnections, changes to database user definitions, and queries executed. This information is useful for security and troubleshooting purposes in Amazon Redshift. Auditing and Logging can be enabled from AWS management console by selecting the cluster for which audit is required.</p><h3>d. Events and Notifications</h3><p>Amazon Redshift tracks all events takes place in Redshift cluster and retains information about them for a period of several weeks in AWS account. For each event, Amazon Redshift reports information such as the date the event occurred, a description, the event source (for example, a cluster, a parameter group, or a snapshot), and the source ID. Redshift event notifications can be setup to monitor activities in the cluster by specifying the filters.</p><p>When an event occurs that matches the filter criteria, Amazon Redshift uses Amazon Simple Notification Service to actively inform the user that the event has occurred.</p><h3>e. Scalability and Elasicity</h3><p>AWS Redshift gives flexibility to add number of compute nodes, change node types as and when needed. It’s simple and quickly scales with few clicks or simple API call. Scaling does not require any downtime, we can continue to run database operations during scaling happens. Provisioning and release of resources can be done on-demand in Redshift.</p><h3>f. Fault Tolrance and High availability</h3><p>Amazon Redshift enhance the reliability of data warehouse cluster by continuous monitoring of the health of the cluster. Redshift is available in multiple Area Zones in various geographical regions. With this feature, selecting nearest area zone latency on database operations can be achieved. In order to achieve high availability or fault tolerance we can replicate Redshift cluster in multiple AZs.</p><h3>g. Vacuum</h3><p>Redshift Vacuum resorts rows and reclaim space in either a specified table or all tables in current database. Timely performing VACUUM on database objects helps to update statistics of that object. These statistics are used by query optimizer to generate query execution plan. There are various parameters we can use with Vacuum:</p><p>· FULL — This is default option. This sorts the table and reclaim the disk space occupied by rows which are deleted or updated. This option does not perform any re-indexing</p><p>· SORT ONLY — Performs only sort operation, does not reclaim space by Delete/Update</p><p>· DELETE ONLY — Performed automatically by the cluster in background. Reclaim disk space</p><p>· REINDEX — Lengthy and time taking operation. It makes additional round to analyze new records/keys. Sort and Merge may take longer than usual to complete</p><h3>h. Security</h3><p>Security is one of the major concern on the cloud for the clients. AWS is responsible for protecting the infrastructure that runs AWS services in the AWS Cloud. Once encryption is enabled on the cluster all data blocks and system metadata is also encrypted. This covers snapshots as well</p><p>Cluster Security — AWS secures cluster with VPC, SSL connections. Security of the cloud is done by AWS and its effectiveness is regularly verified by third-party auditors as part of AWS compliance programs.</p><p>Data Security — Data security is categorized at various levels like data at rest, and in-transit data. In-transit data can be protected by using SSL or by client-side encryption. While data at rest can be done by server side encryption</p><p>Security of the data can be controlled by user accounts, schema in AWS Redshift database. We can limit the user access by granting the permission only for the required resources.</p><p>Encryption can be enabled at the launch of the cluster, or we can modify unencrypted cluster to use AWS Key Management Service (AWS KMS) encryption.</p><h3>i. Cost</h3><p>Cost is the major factor while choosing any infrastructure, service. AWS Redshift have various options for variety of business needs. It simple works on <em>pay as you go </em>model. AWS Redshift is the only cloud data warehouse that provide <em>On-Demand pricing</em> with no up-front costs. Moreover, <em>Reserved Instance</em> <em>pricing</em> can help us to save up to 75% by opting to long-term plan (1 year or 3 years). Cost of the Redshift is derived from various factors like <em>type of node, number of nodes.</em></p><h3>Nodes Pricing (On-Demand)</h3><p>On-Demand pricing model is to pay for the nodes and types of nodes by hour with no upfront costs associated with the cluster. We can change the number of nodes and type of nodes at any point of time based on workload. Best suited for Non-Production like environments. Following table illustrate the On-Demand Pricing:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*q3V-X_nF-sV4-HxkRHrCkg.png" /></figure><h3>Node Pricing — Reserved Instance</h3><p>Reserved nodes/Instance are best fit for Production like systems workload. Reserved nodes helps to gain massive cost saving as compared to on-demand pricing of Redshift Nodes. Reserved instances are available in 1 year or 3 year plan.</p><p>Following factors derive the Node Type and Number of Nodes</p><p>· Volume of data we import into our Redshift cluster</p><p>· Complexity and frequency of the queries on Redshift cluster</p><p>· Number and Need of downstream systems which uses the query result from Redshift cluster</p><h3>6. Operations on AWS Redshift</h3><p>There are numerous operation we can perform on database like query, create, modify or remove database objects, records, loading and unloading data from and to Simple storage service etc. Details are as follows:</p><h3>a. Query</h3><p>Redshift allows to use SELECT statement to extract data from tables. It allows to extract specific columns, restrict rows based on given conditions using WHERE clause. Data can be sorted in ascending and descending order. Redshift allows extracting data using joins, subqueries, call in-built and user defined functions etc.</p><h3>b. DML</h3><p>Redshift allows to perform transactions using INSERT, UPDATE, DELETE commands. DML’s require commit to be saved permanently in database or Rollback to revert the changes. A set of DML’s are known as Transactions. Transaction is completed if any COMMIT, ROLLBACK, or any DDL is performed.</p><h3>c. Loading and Unloading Data</h3><p>Load and Unload operations in Redshift is done by COPY and UNLOAD command. COPY command copies data from files in S3 while UNLOAD dumps the data into S3 buckets in various formats. COPY command can be used to load data into Redshift from data files or multiple data stream simultaneously. Redshift recommends to use COPY command in in case of bulk inserts rather than INSERT.</p><p>Amazon Redshift splits the result of a select statement across a set of one or more files per node slice to simplify parallel loading of data. While unloading the data into S3, files can be generated serially or in parallel. Also, there is a provision to specify the file size. UNLOAD encrypts the data files using Amazon S3 server side encryption (SSE-S3). Max size of a row can be 4 MB in Copy command.</p><h3>d. DDL</h3><p>Specifically known as data definition language. CREATE, ALTER, DROP are names of few can be used to create, modify and delete Database, SCHEMA, USER, and database objects like <em>Tables, views, stored procedure, user defined functions</em> etc. <em>Truncate</em> can used to delete tables data and faster than delete. Truncate releases the space immediately.</p><h3>e. Grant, Revoke</h3><p>Access can be shared and restricted for different set of user groups using Grant and Revoke statements. Access can be granted individually or in the form of roles.</p><h3>f. Functions</h3><p>Functions are data set objects with predefined code to perform a specific operation. They stored in database as precompiled code and can be used in select statement, DML, and in any expression. Functions provide reusability, avoid redundant code. There are two types of functions.</p><h3>i. User defined functions</h3><p>Redshift allows to create a custom user-defined scalar function (UDF) using either a SQL SELECT clause or a Python program. Function must return a value. The user defined functions are stored in the database. User defined functions can be used by user who has sufficient privileges to run. For Python UDFs, in addition to using the standard Python functionality, AWS provide a feature to import own custom Python modules. Functions can be created by CREATE FUNCTION command.</p><h3>ii. In-Built Functions</h3><p>a. Character functions</p><p>b. Number and Math functions</p><p>c. JSON functions</p><p>d. Date Type formatting functions</p><p>e. Aggregate/Group Functions</p><h3>g. Stored Procedures</h3><p>Stored procedures can be created in Redshift using PostgreSQL procedural language i.e. PL/pgSQL. Stored procedures contains the set of queries, logical conditions in its block. Stored procedures stored in database and can be executed/used by user with sufficient privileges. A function does not need to return a value. Parameters in the procedures can be IN, OUT or IN OUT type. We can use DML, DDL, and SELECT statements in stored procedures. Stored procedures can be reused and removes duplicate piece of code</p><h3>7. Where and When Redshift can be used?</h3><p>Today big clients are moving towards on data warehouse service. Redshift can be used in various industries, business use cases who are seeking for a data warehouse cloud service with features like cost savings, powerful engine for complex queries, security etc.</p><p>Clients looking for moving from on premise to cloud model, PaaS model. Traditional setup of servers, data centers for a company was headache. This requires upfront planning, estimation, prediction of servers, type of servers etc. and eventually takes months to come to a conclusion. Any wrong estimation or decision can lead to over or short of the estimated capacity and financial loss or short of resources. Following are business use cases or industries where Redshift can be used:-</p><h3>a. Build Data Lake for pricing data</h3><p>Pricing systems capture data from various exchanges, price publishers and price aggregators to derive the prices. Pricing data is in time series fashion. Historical data can be helpful to implement price forecasting systems for oil, gas, and power sectors. Redshift’s columnar storage is best fit for time series data.</p><h3>b. Consolidation of accounting data</h3><p>Accounting is important vertical of any industry. Companies have their different entities, subsidiary or group companies. They manage their data separately in different systems. Redshift can be used to consolidate the data to see the company’s financial position at company level. Redshift math, analytic, date functions along with user in-built functions to derive various formula and complex customized calculations with optimized performance are very valuable features for accounting.</p><h3>c. Supply chain management</h3><p>Redshift can be used in supply chain companies. Supply chain systems generate huge amount of data. This data is further used planning, scheduling, optimization, and dispatching. To query and analyze huge volume of data feature like parallel processing with powerful node types make Redshift a good option.</p><h3>d. Trading, and Risk Management</h3><p>Consolidation and centralize data of front office, mid office and back office activities. For better management of counterparties, vendor, banks and financial exchanges data. Historical trends of their payments, settlements, compliance provides more insights. This could help to take decision for future trades, decide exposure limits, and mitigate risk against a counterparty. Redshift’s feature data compression, result caching and encryption types to secure critical data makes a suitable data warehouse solution for TRM industry.</p><h3>8. Comparison with other cloud data warehouse services</h3><p>This section illustrates comparison between AWS Redshift and other major cloud data warehouse service providers like Google BigQuery, MS Azure SQL data warehouse. These comparisons are based on factors like storage, security, availability, cost and few others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*ecfMu9KUVPo1BmIFsfnW4A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84e013272841" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>