Tuesday, March 28, 2023

 

Data Pipelines are specific to organizational needs, so it is hard to come up with a tried and tested methodology that suits all, but standard practice continues to be applicable across domains. One such principle is to focus on virtualizing the different sources of data, say into a data lake, so that there is one or at most a few pipeline paths. Another principle is to be diligent about consistency and standardization to prevent unwieldy or numerous customizations. For example, if a patient risk score needs to be calculated, then a general scoring logic must be first applied that is not source specific and then apply an override for a specific source. Reuse can be boosted by managing configurations stored in a database. This avoids a pipeline per data source antipattern.

Pipelines also need to support scalability. One approach to scale involves an event driven stack. Each step picks up its task from a messaging queue and also sends its results to a queue and the processing logic works on an event-by-event basis. Apache Kafka is a good option for this type of setup and works equally well for both stream processing and batch processing.

Another approach to support scalability involves the use of a data warehouse. These help to formalize extract-transform-load operations from diverse data sources and support many types of read-only analytical stacks.

Finally, on-premises solutions can be migrated to the cloud for scalability because of elasticity and higher rate limits. And there is transparency and pay-as-you-go pricing that appeals to the return on investment. Some apprehension about data security precedes many design decisions about on-cloud solutions but security and compliance in the cloud is unparalleled and provides better opportunities for hardening.

Monitoring and alerting increases transparency and visibility into the application and are crucial to health checks and troubleshooting. A centralized dashboard for metrics and alerts tremendously improves the operations of the pipeline. It also helps with notifications.

There are so many technological stacks and services to use in the public cloud that there is always some with missing expertise on the team. Development teams must focus on skills and internal cultural change. Some of the sub-optimal practices happen when leadership is not prioritizing cloud cost optimizations. For example, developers ignore small administrative tasks that may significantly improve operating costs, architects select suboptimal designs that are easier and faster to run but are more expensive to implement, the algorithms and code has not been streamlined and tightened to leverage the best practices in the cloud, deployment automation is neglected or even skipped altogether when they could have correctly adjusted the size of the resources deployed and finally, finance and procurement teams are viewing misplacing their focus on the numbers in the cloud bill and creating tension between them and the IT/development teams. A non-committal mindset towards cloud technologies is a missed opportunity for business leaders because long-term engagements are more cost friendly.

 

Monday, March 27, 2023

Azure data platform continued

 

While the discussion on SQL and NoSQL stacks for data storage and querying has relied on the separation of transactional processing versus analytical processing, there is another angle to this dichotomy from data science perspective.  The NoSQL storage, particularly key value stores are incredibly fast and efficient at ingesting data but their queries are inefficient. The SQL store, on the other hand, is just the opposite. They are efficient at querying the data but ingest data slowly and inefficiently.

Organizations are required to have data stacks that provide the results from heavy data processing in a limited time window. SQL databases are also overused for historical reasons. When organizations want the results of the processing within a fixed time window, the database’s inefficiency to intake data delays the actual processing which in turn creates an operational risk.  The limitation comes from the data structure used in the relational database. Storing a 1 TB table requires the B+ tree to grow to six levels. If the memory used by the database server is of the order of 125 GB, less than 25% of the data will remain in cache. For every insertion, it must read an average of three data blocks from disk to read the leaf node. This will cause the same number of blocks to be evicted from the cache. This dramatic increase in I/O makes these databases so inefficient to ingest data.

When the data is stored in the NoSQL stores, the querying is inefficient because a single horizontal data fragment could be spread across many files which increases duration in reading the data. This improves if there is an index associated with the data but the volume of data is still quite large. If a single B+ tree is assumed to have 1024 blocks, each search will need to access log (1024) = 10 blocks and there could be many files each with its own index, which means if there are 16 B+ trees, a total of 160 blocks would be read instead of the 10 blocks in one index in a database server. Cloud document stores are capable of providing high throughput and low latency for queries by providing a single container for unlimited sized data and charging based on reads and writes. To improve the performance of the cloud database, we must set the connection policy to direct mode, set the protocol to TCP, avoid startup latency on first request, collocate clients in the same Azure region for performance and increase the number of threads/tasks.

Ingestion is also dependent on the data sources. Different data sources often require different connectors but fortunately they come out-of-the box from cloud services. Many analytical stacks can easily connect to the storage via existing and available connectors reducing the need for integration. Services for analysis from the public cloud are rich, robust and very flexible to work with.

When companies want to generate value and revenue from accumulated data assets,  they are not looking to treat all data equally like some of the analytical systems do. Creating an efficient pipeline that can scale to different activities and using appropriate storage and analytical systems for specific types of data helps meet the business goals with rapid development. Data collected in these sources for insurance technology software could be as varied as user information, claim details, social media or government data, demographic information, current state of the user, medical history, income category or credit score, agent customer interaction, and call center or support tickets.  ML templates and BI tools might be different for each of these data categories but the practice of using data pipelines and data engineering best practices bring cloud-first approach that delivers on the performance requirements expected for those use cases.

Sunday, March 26, 2023

 Business process automations provide immense opportunities for improvements as ever and more so when there is pressure both inside and outside an organization as is the case in the insurance sector that infuse new ways of doing business and continually challenge traditional ways.  Some of these trends can be seen with examples, such as, when Lemonade has streamlined the claims experience by using AI and chatbots, Ethos issues life insurance policies in minutes, Hippo issues home quotes in under a minute, Telematics based auto insurance companies like Metromile and Root offer usage based insurance, Fabric offers value-added services in its niche market, Figo Pet empowers a completely digital pet insurance platform and Next Insurance simplifies small business insurance with a 100% online experience. In this sector, incumbent insurers have insufficient customer-centric strategies and while the establishment view the niche product from these incumbents as merely threats, they run the risk of increasing their debt with their outdated processes and practices which results in lower benefits to cost ratio. The gap also widens between the strategies offered by the incumbents and those provided by the established. Incumbents channel technology best practices and are not bound by industry traditions. Zero-touch processing, self-service and chatbots are deployed to improve customer -centric offerings. Industry trends are also pushing customers more and more to digital channels. The net result is that the business is increasingly driven towards digital-enabled omnichannel, and customer-aligned customer experience and established business have the advantage to strive for scale. This is evident from the increased engagement with digital leaders from inside and outside the industry and with the new and improved portfolio of digital offerings.

A digital transformation leader sees the opportunities and challenges for these business initiatives with a different point of view. It can be broken down into legacy and new business capabilities and with different approaches to tackle them. While established companies in this sector have already embraced the undisputed use of cloud technologies and have even met a few milestones on their cloud adoption roadmap, digital leaders increasingly face the challenges of migrating and modernizing legacy applications both for transactional processing as well as analytical reports. The journey towards the cloud has been anything but steady due to the diverse technological stack involved in these applications. A single application can be upwards of a hundred thousand lines of code and many can be considered boutique or esoteric in terms of their use of third-party statistical software and libraries. What use to be streamlined and tuned analytical queries against data warehouses, has continually evolved to using Big Data and stream analytics software often with home-grown applications or internal facing automations.

Saturday, March 25, 2023

 

A previous post introduced some of the best practices using Azure Data Platform. It covered various options about structured and unstructured storage. This article covers some of the considerations regarding data in transit.

Azure Data Factory is frequently used to extract-transform-load data to the cloud. Even if there are on-premises SSIS data tasks to perform, Azure Data Factory can help to migrate the data from on-premises to the cloud. There are different components within the Azure Data Factory that help to meet this goal. The Linked Services provide connections to external resources that contain datasets to work with. The Pipeline has one or more activities that can be triggered to control/transform the data. The Integration Runtime provides the compute environment for data integration execution that involves flow, transform and movement. This can be Azure-based, self-hosted and an integration of Azure-SSIS that can lift and shift existing SSIS workloads. The pipeline and activities define actions to perform on the data. For example, a pipeline could contain a set of activities that ingest and clean log data and then kick off a mapping data flow to analyze the log data. When the pipeline is deployed and scheduled, all the activities can be managed as a set instead of each one individually. Activities can be grouped into data movement activities, data transformation activities, and control activities. Each activity can take zero or more input and output datasets. Azure Data Factory enables us to author workflows that orchestrate complex ETL, ELT and data integration tasks in a flexible way that involves graphical and code-based data pipelines with Continuous Integration / Continuous Deployment support.

Let us take a scenario for a company that has a variety of data from a variety of sources and requires automations for data ingestion and analysis in the cloud. It has a variety of data available, from a variety of sources and requires expertise in business analysis, data engineering, and data science to define an analytics solution. For this purpose, it leverages the new data analytics platform in Azure that has been discussed so far. The current practice in this company captures a variety of data about manufacturing and marketing and stores it in a centralized repository. The size of this repository limits the data capture to about one week’s worth of data and supports data formats in the form of json, csv, and text. Additionally, data also exists in another cloud in a publicly available object storage. The company is expecting to meet the following objectives with regard to data storage, data movement, and data analytics and insights. The data storage must be such that months of data to the tune of petabytes can be stored and support access control at the file level. Data must be regularly ingested from both the on-premises and AWS. The existing connectivity and accessibility to data cannot be changed. The analytics platform must support Spark and be available to the other cloud. Security demands the workspace used for analytics must be made available only to the head office.

A possible solution for the above scenario is one that could store the data in the Azure Data Lake Storage Gen2 because it scales to petabytes of data and comes with hierarchical namespace and POSIX-like access control list. The data can be copied or moved with Azure Data Factory that has a self-hosted integration runtime that is running on-premises and can access the on-premises storage privately. Even when certain data might be in the other cloud, Azure Data Factory can leverage the built-in Azure Integration runtime to access it. There are many services to choose from for the analytics solution, but Databricks provides the analytics because it could potentially work in both public clouds. The premium plan for Databricks can restrict the workspace use only to the head office. It also supports Azure AD credential pass-through when it is to be used for securing data lake storage.

 

Friday, March 24, 2023

Some best practices using Azure Data Platform: 

Structured and Unstructured data required different storage and processing. Structured data is a fixed format data with schema, types, and relationships. It requires a lot of upfront planning and is equally difficult to modify afterwards. It is frequently used to store application data for online transaction processing. The semi-structured data is very flexible format with various models such as key/value, document, etc. The emphasis is on long-term flexibility and modifications and is best suited to dynamic applications such as social media. Media files, text files and office documents are most frequently used unstructured data. 

Azure storage accounts can store blobs, queues, files and blocks. The kind of storage account determines the supported storage services, performance tier, and pricing. Data can be replicated in the primary region to a secondary region. The access tier influences the pricing and access latency. The hot, cool or archive access tiering suits data ageing and supports lifecycle management. The Gen2 storage supports hierarchical namespace. Object data can be streamed globally, and at scale. Lower latency and higher throughput come with performance tiers. Replication and accessibility must be part of the design decisions. 

Companies that require relational databases have a variety of products and offerings from Azure. They can choose to directly host a database on Azure using a fully managed offering that supports common SQL Server features. Otherwise, they could choose to deploy a managed SQL Server instance. If they want even more parity and control with a traditional on-premises database, then they could create Azure SQL Server virtual machines which provide full control and access. Those three options are ordered in terms of trade-offs between cloud native and full control and access. Cloud native resources come with built-in backup, patching, and recovery and provide 99.995% availability guarantee. They also integrate with Azure Active Directory. Azure SQL managed instances are deployed on a managed virtual cluster that Microsoft manages. It provides a private IP address and support for most migrations to the cloud. The SQL purchasing models can be DTU-based for predictive and linear increase between compute and storage or vCore based for scattered and independent compute versus storage. vCore also supports Azure Hybrid Benefits which supports porting on-premises SQL Server licensing. The General Purpose Service Tier uses blob storage at about 5-10 ms latency, the Business Critical uses SSD at about 1-2 ms latency and 16TB database, and Hyperscale supports up to 100TB databases. Azure SQL virtual machines provide full control and access with relaxed limits. 

The Data Lake storage is ideal to store huge amounts of varied or unstructured data and is built on top of block blobs. It enables common analytical features and access and is especially useful to store large volumes of text with support for hierarchical namespaces. It is accessible by Hadoop services and supports a superset of POSIX for finer-grained access controls. Synapse Analytics combines data warehousing and big data analytics. It has tools for data integration from diverse sources and powers analytics with massively parallel processing. The resource pools can be SQL pool, Spark pool and Synapse supports pipelines for data movement and transformation using Azure Data Factory workflows and supports connectivity to CosmosDB for near real-time analytics. The models served by Synapse can be rich. Databricks are favored for Apache Spark-based big data and machine learning. Environments with Databricks can run SQL queries on a data lake, provide a collaborative workspace for working on big data pipelines and analytics and end-to-end integrations for ML experiments, model training and serving. The premium tier can help with management, security and monitoring with audit logs, notebooks, cluster, job RBAC, Azure AD passthrough and IP access lists. 

The right choices for cloud engineering can bring tremendous value to data engineering professionals. 

Thursday, March 23, 2023

Linux kernel extensions continued

 

Application development frequently encounters the need for background tasks or scheduled jobs. Long running tasks are often delegated to background workers. In fact, some models require a state reconciliation control loop that is best met by background workers. This idea is frequently encountered with infrastructure providers. For example, Kubernetes has a language that articulates state so that its control loop can reconcile these resources. The resources can be generated and infused with specific configuration and secret using a configMap generator and a secret generator respectively. It can take an existing application.properties file and generate a configMap that can be applied to new resources.

FUSE can also be used with remote folders. Mounting a remote folder is a great way to access information on a remote server. Mounting the folder into the filesystem will allow us to drag and drop files into the required folder and the information will then be transferred to the remote location. For example, the following commands can be used to set this up:

yum install epel-release -y

yum install fuse sshfs -y

modprobe fuse

lsmod | grep fuse

echo “modprobe fuse” >> /etc/rc.local

ssh root@198.162.2.9:/home/mount /home/remote

Wednesday, March 22, 2023

Linux Kernel Continued...

 

Linux also supports FUSE which is a user-space file-system framework. It consists of a kernel module (fuse.ko), a userspace library(libfuse.*) and a mount utility (fusermount). One of the most important features of FUSE is allowing secure non-privileged mounts. One example of this is the sshfs which is a secure network filesystem using the sftp protocol.

One of the common applications for FUSE filesystem is the use of a Watchdog to continuously monitor a folder to check for any new files or when an existing file is modified or deleted. As an example, if the size of the folder exceeds a limit, then it can be pruned. Watchdog is an open-source cross-platform python API library that can be used to monitor file systems. The Watchdog observer keeps monitoring the folder for any changes like file creation and when an event occurs, the event handler executes the event’s specified action.

Such usage is very common when there are a lot of files being uploaded to a file directory, let us say a hot folder and those files may never be used once they are processed. It helps to keep the file contents of the hot folder under a certain size limit for performance reasons. Therefore, another folder is created to roll over the contents from the hot folder. Let us call this folder the cold folder. It might so happen that processing might not have caught up with a file in the hot folder  and it is moved to the cold folder. The application then needs to check the hot folder first and then the cold folder and with the help of an attribute or a modification to the file name or the presence of an output file, detect if the file has been processed. The hot and cold folder are interchangeable for reading from and writing to the file. Since FUSE provides a bridge to the actual kernel interfaces, the library providing event handling interfaces can extend it to pass through the file operations without requiring the application to know whether the hot or cold folder is used. The only overrides to the operating system file system operations would be to resolve the appropriate folder.