{{announcement.body}}
{{announcement.title}}

Time Warping On AWS Elastic Beanstalk

DZone 's Guide to

Time Warping On AWS Elastic Beanstalk

Learn more about how AWS Elastic Beanstalk is useful in time warping as an application of the analysis of multiple models or algorithms.

· Cloud Zone ·
Free Resource

time warp

Using AWS Elastic Beanstalk for time warping

From its inception, AWS Elastic Beanstalk was designed to reduce the complexity of running web applications in the cloud. Elastic Beanstalk is also designed from the ground up to support multiple programming languages, including Node.js and Python.

As a platform, Elastic Beanstalk eliminates most of the hard work in setting up the right infrastructure for your web apps. You don’t have to manually provide resources or deal with infrastructure maintenance. This allows developers to focus on creating, deploying, and maintaining their apps instead.

One of the instances in which AWS Elastic Beanstalk becomes incredibly handy is in deploying apps that rely on data processing and analysis, specifically analysis that utilizes multiple models or algorithms. In this article, we are going to focus on the use of Elastic Beanstalk for time warping.

You may also enjoy: Deployment Orchestration With AWS Elastic Beanstalk

Finding Similarities

Time warping allows the processing of data across multiple time series, a common approach used in deeper analysis. Applications of time warping include examining deterministic build processes, debugging any time-related issues in your infrastructure—such as expired SSL certificates — or testing software for future diagnostics — such as year-2038 compliance, for example.

The most common form of time warping is dynamic time warping (DTW), which compares and analyzes multiple time series.

DTW enables optimized algorithms to conform to certain warping functions. The process starts with the division of two series of data into equal points, which are then converted into a time warp; the process basically uses the Euclidean distance between points in the series to find similarities.

The previous process is repeated for every data point in the time series until all of them are analyzed. Warping has its restrictions to allow for more accurate calculation, with boundary conditions and slope constraint being the most common restrictions of them all.

Time Warping In Real Life

The implementation of time warping is endless, but the most common implementation can be seen in weather and temperature analysis. When comparing temperatures in two areas or more, scientists regularly utilize time warping to synchronize data points.

Time warping is also used in more advanced fields, including in the development of artificial intelligence and augmented reality applications. In the case of AI, time warping is used to interpolate signal values from two datasets in order to increase accuracy.

Assuming that there are two data streams, the analysis is conducted using warping function φ in order to generate ˜x = x ◦ φ ≈ y. As this form of analysis—as well as generalized time warping and canonical time warping—gets used more frequently, frameworks and modules are released to simplify the process.

A good example of time warping being deployed as a platform can be seen in the implementation of MetProt, a Node.js-based time-warping tool that supports datasets in .csv and .rdata formats. Since MetProt is based on Node.js, it runs smoothly on AWS Elastic Beanstalk and is always ready for immediate use.

Time Warping In The Cloud

Sticking with MetProt as an example, you get a platform that can be used to analyze external data in the right format. As the name suggests, MetProt is a platform that analyzes and annotates Metabolomics datasets with Proteomics information. Chemical processes are analyzed from the datasets without time series being a serious obstacle.

Similar solutions—or even custom-built ones—can be deployed in an instant on Elastic Beanstalk. Since AWS Elastic Beanstalk can also be configured for certain computational needs, you can refine how the infrastructure is set up down to the kind of EC2 set up supporting the environment just as easily. Another example implementation is the GitHub tool libfaketime, a tool that easily modifies the system time for applications. Running libfaketime on your Amazon applications consists of two steps:

1. Making sure libfaketime gets loaded by the system’s linker.

2. Specify the faked time.

The tool works by intercepting various system calls that apps leverage to retrieve the current date and time. It then feeds back modified (warped) dates and times configured by the user. This means you can modify the system time a program sees without having to change the time system-wide.

At Ibexlabs, we have been using this libfaketime library for our Java application hosted in AWS Elastic Beanstalk. Our application does calculations on different dates in the future for our data analysis in this manner. Here’s an example of the time warping process in action:

Libfaketime And AWS Elastic Beanstalk

  • First, we have to clone the repository from Github here and compile it using make , which will create our Beanstalk required files in the src/ directory.
  • Create one folder in beanstalk extensions, e.g., "libfaketime," and copy files "libfaketime.so.1" and "libfaketimeMT.so.l" taken from the src/ directory to the "libfaketime" extensions folder.
  • We have been using the following variables set on Beanstalk environment properties to change the time for the application.
Java




x


 
1
DONT_FAKE_MONOTONIC=1
2
FAKETIME=@YYYY-MM-DD HH:mm:ss
3
FAKETIME_NO_CACHE=1
4
LD_PRELOAD=/var/app/current/faketimefiles/libfaketime.so.1


One important thing to note is that we should also create one IAM user with  AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY   and add those to the Beanstalk environment properties because an instance attached without IAM role permissions won’t work on future dates as expected.

  • Next, create a custom script to update the Beanstalk environment properties to add the required variables using the AWS CLI to change multiple dates automatically. We have been using Jenkins to run through different dates with given parameters over certain intervals.
  • The following is the example AWS CLI command to update the environment properties on Beanstalk:
Shell




xxxxxxxxxx
1


 
1
aws elasticbeanstalk update-environment –environment-name $BACKEND_ENVIRONMENT –option-settings
2
Namespace=aws:elasticbeanstalk:application:environment,OptionName=FAKETIME,Value=$FAKE_TIME
3
Namespace=aws:elasticbeanstalk:application:environment,OptionName=LD_PRELOAD,Value=/var/app/current/faketimefiles/libfaketime.so.1
4
Namespace=aws:elasticbeanstalk:application:environment,OptionName=FAKETIME_NO_CACHE,Value=1
5
Namespace=aws:elasticbeanstalk:application:environment,OptionName=DONT_FAKE_MONOTONIC,Value=1
6
Namespace=aws:elasticbeanstalk:application:environment,OptionName=AWS_ACCESS_KEY_ID,Value=$AWS_ACCESS_KEY_ID
7
Namespace=aws:elasticbeanstalk:application:environment,OptionName=AWS_SECRET_ACCESS_KEY,Value=$AWS_SECRET_ACCESS_KEY” –output json


  • To change the date back to the original, you can just remove the additional Beanstalk environment properties added. The following is the example AWS CLI command to remove environment properties on Beanstalk:
Shell




xxxxxxxxxx
1


 
1
aws elasticbeanstalk update-environment –environment-name $BACKEND_ENVIRONMENT –options-to-remove 
2
Namespace=aws:elasticbeanstalk:application:environment,OptionName=FAKETIME 
3
Namespace=aws:elasticbeanstalk:application:environment,OptionName=LD_PRELOAD 
4
Namespace=aws:elasticbeanstalk:application:environment,OptionName=FAKETIME_NO_CACHE 
5
Namespace=aws:elasticbeanstalk:application:environment,OptionName=DONT_FAKE_MONOTONIC 
6
Namespace=aws:elasticbeanstalk:application:environment,OptionName=AWS_ACCESS_KEY_ID 
7
Namespace=aws:elasticbeanstalk:application:environment,OptionName=AWS_SECRET_ACCESS_KEY –output json


Finally, with time warping there is no need to be concerned about scaling as that’s also not an issue. As your computational need grows, Elastic Beanstalk can make the necessary adjustments and maintain cloud environment health. A quick look at the Enhanced Health Overview is all you need to maintain a healthy cloud environment.

One thing's for sure: Elastic Beanstalk makes time warping more accessible. Researchers, developers, and data scientists can fully take advantage of the AWS cloud environment for data processing and analysis without having to be a master of server and cloud management.

Further Reading

What the Heck Is Time-Series Data (And Why Do I Need a Time-Series Database?

Strava: Calculating the Similarity of Two Runs

Topics:
aws ,time ,elastic beanstalk ,libfaketime ,time warp ,cloud ,data analysis

Published at DZone with permission of Kiran Sangeetam . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}