Tutorials and How-To’s for Amazon Web Services (AWS)

Amazon Web Services S3 upload bug

The AWS Java SDK Version 1.8.10 comes with a critical bug, affecting uploads. A fix was provided by AWS and normally the SDK is updated automatically, so you don’t need to worry.
However, if automatic updates are disabled in your Eclipse Version, you might loose data when uploading via the SDK Version 1.8.10. Here is what AWS has to say about the bug:
//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js //

AWS Message

Users of AWS SDK for Java 1.8.10 are urged to immediately update to the latest version of the SDK, version 1.8.11.
If you’ve already upgraded to 1.8.11, you can safely ignore this message.
Version 1.8.10 has a potential for data loss when uploading data to Amazon S3 under certain conditions. Data loss can occur if an upload request using an InputStream with no user-specified content-length fails and is automatically retried by the SDK.
The latest version of the AWS SDK for Java can be downloaded here:
http://aws.amazon.com/sdk-for-java/
And is also available through Maven central:
http://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk/1.8.11/


The bug itself is repaired, in case you didn’t update the AWS SDK and are on the SDK Version 1.8.10 you should update that. Normally, the AWS SDK updates itself automatically in Eclipse.

Amazon Web Services Short Tips: Get SQS Queue URL with Java

I will post some Developer content from now on, with a focus to some easy but helpful tasks when working with various Cloud Platforms. These tips will be named after the service (e.g. Amazon Web Services for AWS, …)
The first tip I want to show is how to retrieve the full queue URL when you already have the queue name:

sqs.getQueueUrl(new GetQueueUrlRequest().withQueueName("myqueue")).getQueueUrl();

The function “getQueueUrl()” already returns a String-representation and not a URI itself (this is what I would rather expect in that case)

Announcement: New E-Book – Amazon Web Services for .NET Developers

I am happy to announce that my new E-Book is in stores now! The book is 85 pages in lenght and the target for the book is to provide an overview of Amazon Web Services for .NET Developers. The E-Book by “developer.press” is called “Shortcut” and aims at delivering this topic in one or two evenings to read right after work.

Amazon Web Services for .NET Developers

Amazon Web Services for .NET Developers


The book starts with a description of the service categories offered by Amazon with a brief description of available services. Due to the fact that Services are released often and the book authoring timeframe is about 3-6 month, services such as Amazon Glacier are not yet included. The other 6 chapters focus entirely on building an Application with AWS. Amazon Elastic Beanstalk is used with Asp.NET MVC. Next, a focus on S3, SQS, DynamoDB and Amazon EC2 is given.
Subscribe to this channel to get updates about the book.
You can download the Source Code here.
The book is currently available only in German, an English Version is planned.
The E-Book is available in the iTunes Store and in the Kindle Store.

Error in AWS SDK for PHP: cURL error: SSL certificate problem

When using the AWS SDK for PHP, you might run into a SSL certificate problem. This problem could look like the following:
 
//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js //
Fatal error: Uncaught exception ‘cURL_Exception’ with message ‘cURL resource: Resource id #18; cURL error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (cURL error code 60). See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of error codes.’ in C:Program Files (x86)PHPv5.3pearAWSSDKforPHPlibrequestcorerequestcore.class.php:843 Stack trace: #0 C:Program Files (x86)PHPv5.3pearAWSSDKforPHPsdk.class.php(1034): RequestCore->send_request() #1 C:Program Files (x86)PHPv5.3pearAWSSDKforPHPservicesses.class.php(399): CFRuntime->authenticate(‘SendEmail’, Array) #2 C:inetpubwwwrootwordpresswordpresswp-contentthemestwentyelevensingle.php(23): AmazonSES->send_email(‘mario.mh@cloudv…’, Array, Array) #3 C:inetpubwwwrootwordpresswordpresswp-includestemplate-loader.php(43): include(‘C:inetpubwwwr…’) #4 C:inetpubwwwrootwordpresswordpresswp-blog-header.php(16): require_once( in C:Program Files (x86)PHPv5.3pearAWSSDKforPHPlibrequestcorerequestcore.class.php on line 843
The reason for this is that you might have misconfigured your Certificate Settings. To find that section, go to your “config.inc.php” File in your SDK’s Directory. The file is used to store your credentials and connection settings. Find the variable that says “certificate_authority”. If it is set to “false”, you have to specifiy the File that holds your Connection Settings. If you use the SDKs File (if you haven’t changed any SSL settings), change this value to “true”. Now you should be fine. Make sure that your SSL settings are secure and avoid “man in the middle” attacks!

Source Code for AWS and .NET Sample

The Source Code for the e-book is now available at Codeplex.
The Sample includes the following Services:

  • Amazon EC2
  • Amazon SQS
  • Amazon S3
  • Amazon DynamoDB
  • Amazon Elastic Beanstalk

The Sample is written in C# and uses Asp.NET MVC, Asp.NET Web API and AWS SDK for .NET

Creating a distributed, scalable WordPress Platform on Amazon Web Services (AWS)

For CloudVane.com we wanted to have a highly scalable, distributed and performing Platform that is also easy to Maintain. These challenges weren’t that easy to achieve and initially we had to find a system.  As CloudVane is all about the Cloud, the solution was easy: it must be a Cloud Provider. We selected Amazon Web Services to server our Magazine.
To better understand the Performance of WordPress, we wanted to have a System that allows us to handle about 8 million hits per day. So we started with a standard WordPress Installation on Ubuntu with MySQL just to figure out what is possible (and what not). We didn’t add any Plugins or so, the first tests were a really plain System.
For the Test, we used Blitz.io, which returns great statistics about the Test run. Our first Test gave us the following results:

  • Delay: 477 MS FROM VIRGINIA
  • 60 Seconds Test Run with 20 Users per Second at maximum
  • Response with 20 Users per Second was about 1 Second

So what does this mean? First of all, we can handle about 20 Users per second. However, the delay of 1 second is not good. Per Day, we would handle about 560,000 hits. So we are still far away from our target of 8 Million Hits per day. The CPU Utilization wasn’t good either – it turned out that our instance takes 100%. So this is the very maximum of an Out-of-the Box WordPress installation. Below you can see some graphics on the Test run.
Test Run #1:
60 Seconds, maximum of 20 Users per Second:

Performance for an AWS Micro Instance measured by a Load Test

Performance for an AWS Micro Instance measured by a Load Test


Amazon Performance with WordPress and a Micro Instance on EC2

Amazon Performance with WordPress and a Micro Instance on EC2


As you can imagine, this simply does not meet our requirements. As a first step, we wanted to achieve better scaling effects for CloudVane.com. Therefore, we started up another Micro Instance with Amazon RDS. On the RDS Instance, we took advantage from the ready-to-use MySQL Database and connected it as the primary database for our WordPress Platform. This gives us better scaling effects since the WordPress instance itself doesn’t store our data anymore. We can now scale out our database and Web frontend(s) independent from each other.
But what about images stored on the Platform? They are still stored on the Web Frontend. This is a though problem! As long as we store our images in the instance, scaling an instance gets really though. So we wanted to find a way to store those instances on Blob Storage. Good to know that Amazon Web Services offers a Service called “Simple Storage Service” or “S3” in short. We integrated this service to replace the default storage system of WordPress. To boost performance, we also added a Content Distribution Network. There is another Service by Amazon Web Services, called “Cloud Front”. With Cloud Front, Content is delivered from various Edge-Locations all over the Globe. This should boost the performance of our Platform.
As a final add-on, we installed “W3 Total Cache” to boost performance by Caching Data. This should also significantly boost our performance. But now lets have a look at the new Load Test, again with Blitz.io. For our Test, we use the maximum we can do with our free tier: 250 concurrent users.
The output was:

  • An average of 15ms in delay
  • More that 10 million hits per day

Summing this up, it means that we achieved what we wanted: a fully scalable, distributed and performing WordPress platform. It is nice what you can do with a really great architecture and some really easy tweaks. Below are some graphics of our test run.

Load Testing an Amazon Web Service Micro Instance with Caching

Load Testing an Amazon Web Service Micro Instance with Caching


Amazon CPU Load on a Micro Instance with Caching and CDN

Amazon CPU Load on a Micro Instance with Caching and CDN

Creating a simple WordPress Blog with the Bitnami Stack on Amazon EC2

It is really easy to create a simple WordPress Blog on Amazon EC2 with the Bitnami Stack. To do so, simply click on “Launch Instance” in the Console.

Launch a new AWS Instance

Launch a new AWS Instance


 
Next, we get a Dialog where we can select the Wizard. For our sample, we use the “Classic” Wizard.
 
Create a new AWS EC2 Instance with the Wizard

Create a new AWS EC2 Instance with the Wizard


In the „Request Instances Wizard“, we now select the Tab „Community AMIs“ and type „wordpress“ in the Search Box. This will list us several WordPress-Enabled Instances.
 
Available AWS Community AMIs

Available AWS Community AMIs


We select an AMI that has the most recent WordPress Version installed. In the current case, it is “ami-018c8875“ but it might change over time.
In the next Dialog, we make sure to have “Micro” as Instance Type selected. This is the cheapest available instance type on EC2.
 
Select an instance type on AWS

Select an instance type on AWS


We simply confirm the next few Dialogs until we get to the point where we need to create a Key/Value Pair. This is necessary once we need to connect to the instance.
 
Create a new Key-Pair for an EC2 Instance on AWS

Create a new Key-Pair for an EC2 Instance on AWS


In the last Dialog simply click “Launch” and the Instance will be started.
Don’t forget to configure the security groups. If it is your first time with AWS, you might not have set HTTP Connections by the Firewall.
Amazon Web Services, the “Powered by Amazon Web Services” logo, are trademarks of Amazon.com, Inc. or its affiliates in the United States and/or other countries.