Just start typing...
Technologies

Programmable load balancing on NoSQL database (DynamoDB)

Published July 23, 2014

The top priority for the high-load systems is to provide continuous access to the information. For one of our projects, we used DynamoDB‎ to ensure the maximum stress resistance and minimum delays, and reduce the user’s waiting time.

The average Internet user sees about 200 advertisements per day. Such a variety of advertising messages creates a high level of information "noise" which the well experienced users have learned to ignore. So ad performance decreases significantly, and we have to look for new, more prominent ad formats that can get through the advertising "noise."

Also modern consumers will not believe the advice of some Ph.D. or “Doctor of the Year” – they need to confirm the information provided on the website or in promotional materials, and preferably from a familiar person. This approach brings the concept of “word-of-mouth” to a completely new level.

Does anybody use this “technology” now?  No. Its effect can’t be calculated in reports on Facebook or Google Analytics, which is so important to advance for marketers and managers. A fact that can’t be calculated or measured does not exist. The sets of metrics that social networks have can’t describe the way in which people came to the idea to buy your product or service. It’s not possible to calculate the social effect for advertisement in Internet without creating a link between distribution, adverts and communications of potential buyers - this link is Bamboo by Manumatix Inc.

What is the easiest way to find new customers? Right, create the conditions for most committed customer to talk about your product. You must provide them an easy way to tell their friends how wonderful your product is: send messages and invitations to a social network, send an emails or tweet about your product – and everything in a form that the user prefers. All this mechanisms are provided by Bamboo: integration with the most popular social networks (such as Facebook, Twitter, Google+, Pinterest, Tumblr), the detailed configuration of promotions (website, embedded ads, app or fan page on Facebook etc.) and, most important, the full report coverage of user actions from coming to landing page to purchasing goods in offline store. Using Bamboo you will drastically reduce the advertisement budgets (ex.: for every $1000 you will receive ~20K clicks instead of 1K on banners).

In high loaded systems, which Bamboo is, the first priority is to provide continuous access to the information. So it was decided to use the Amazon product for maintenance and storage. The system itself operates in a private cloud (EC2). This approach provides the maximum stress resistance and minimum delays due to geographical distribution of data processing centers. The user information is stored in NoSQL database DynamoDB that also reduces the waiting time of the user.

Another DynamoDB useful feature is a throughput management either from user interface or programmatically. Screen of table with options shown below.

Throughput Properties Representation

Picture 1. Throughput properties representation.

Using the menu “Modify Throughput” you can open the configuration dialog.

Throughput Configuration Dialog, DynamoDB, NoSQL, Google Guava RateLimiter, Bamboo, DynamoDB, integration with social networks, advertisement

Picture 2. Throughput configuration dialog.

NB! The throughput can’t be increased more than by a factor of two and can’t be reduced more than 10%.

This configuration allows manipulating provisioned capacity - the number of operations per time unit, which guaranteed by Amazon. However, distributed architecture of informational systems makes it difficult to separate modules to work with their own set of tables in database. Usually business processes require modules to cooperate between them. In this case, the bandwidth management is on leading role. And there is a solution – programmatic configuration of throughput using the RateLimiter by Google Guava. Consider solution within Java.

Assume that you need to perform calculations on the data stored in database. Use the following implementations to solve this problem:

  1. Get configured reading throughput
  2. Use RateLimiter to limit the number of calls to API
  3. Scan selection of 100 entities
  4. Perform required calculations

This solution is listed below.

// limit the rate to 50% of configured throughput
  float ALLOWED_SCAN_CONSUMPTION_RATIO = 0.5f;
  // connect to the table
  TableDescription tableDescription = dbConnection.describeTable( someTableName ).getTable();
  // get configured reading throughput
  long provisionedReadCapacity = tableDescription.getProvisionedThroughput().getReadCapacityUnits();
  // calculate the final rate limit
  long allowedConsumption = Math.max( 1, Math.round( provisionedReadCapacity * ALLOWED_SCAN_CONSUMPTION_RATIO ) );
  // create RateLimiter object with calculated limit
  RateLimiter rateLimiter = RateLimiter.create( allowedConsumption );
  Map< String, AttributeValue > lastKeyEvaluated = null;
  int permitsToConsume = 1;
  do {
   // acquire() will pause the thread if you exceed the limit
    rateLimiter.acquire( permitsToConsume );
   // scan request to the database
    final ScanRequest scanRequest = new ScanRequest()
        .withTableName( someTableName )
        .withLimit( 100 )
        .withExclusiveStartKey( lastKeyEvaluated )
   // NB! Ask the Amazon API to return consumed capacity
        .withReturnConsumedCapacity( ReturnConsumedCapacity.TOTAL );
    final ScanResult scanResult = dbConnection.scan( scanRequest );
    for( Map< String, AttributeValue > record : scanResult.getItems() ) {
      // perform required calculations
    }
    lastKeyEvaluated = scanResult.getLastEvaluatedKey();
    final double consumedCapacity = scanResult.getConsumedCapacity().getCapacityUnits();
   // calculate new value of consumable capacity for RateLimiter
    permitsToConsume = ( int )( consumedCapacity - 1.0 );
    if( permitsToConsume <= 0 ) {
      permitsToConsume = 1;
    }
  } while( lastKeyEvaluated != null );
  
  

Suggested solution can make the entire system more flexible. In addition, it reduces server load, which in turn can reduce the costs of Amazon provided services.

Using the latest technologies to maintain the platform in addition to unconventional approach of the potential buyers interaction with the system is an innovate idea implemented in Bamboo. The solution from Manumatix Inc. will be the most efficient way to use the advertisement budget – it will increase profits at the expense of social interactions of your customers.

Related Services

Application Development
DevOps Services
Software Optimization

How we process your personal data

When you submit the completed form, your personal data will be processed by WaveAccess USA. Due to our international presence, your data may be transferred and processed outside the country where you reside or are located. You have the right to withdraw your consent at any time.
Please read our Privacy Policy for more information.