jgillman's Liquid Web Update Unofficial tips, tricks, and happenings from a Liquid Web sales engineer

3Apr/120

Updated Storm On Demand API PHP Class

I just wanted to put out that I've updated my API class to use cURL instead of HTTP_REQUEST2 in my initial post.

Although it still utilizes YAML, this is my first move at getting away from third party packages.

Enjoy!

 PHP | 
 
 copy code |
?

01
02
<?php
03
	/*
04
	 * Author: Jason Gillman Jr.
05
	 * Description: This is my attempt at writing a PHP wrapper that will ease Storm API calls with PHP
06
	 * 				It will be designed to use the YAML format for talking with the API server.
07
	 * 				$api_method is as described in docs (Case matters)
08
	 * 				request() method returns an array generated from the API return
09
	 */
10
	class StormAPI
11
	{
12
		// Let's define attributes
13
		private $api_user, $api_pass, $base_url, $api_format, $api_full_uri, $api_request;
14
		private $api_request_body, $api_method, $api_params, $api_return; 
15
 
16
		function __construct($api_user, $api_pass, $api_method)
17
		{	
18
			$this->api_user = $api_user;
19
			$this->api_pass = $api_pass;
20
			$this->api_method = $api_method;
21
			$this->base_url = 'https://api.stormondemand.com/';
22
			$this->api_format = 'yaml';
23
 
24
			$this->api_full_uri = $this->base_url . $this->api_method . "." .$this->api_format;
25
			$this->api_request = curl_init($this->api_full_uri); // Instantiate
26
			curl_setopt($this->api_request, CURLOPT_RETURNTRANSFER, TRUE); // Don't dump directly to output
27
			curl_setopt($this->api_request, CURLOPT_SSL_VERIFYPEER, FALSE); // Apparently verification doesn't work with the API?
28
			curl_setopt($this->api_request, CURLOPT_USERPWD, "$this->api_user:$this->api_pass"); // Pass the creds
29
		}
30
 
31
		function add_param($parameter, $value)
32
		{
33
			$this->api_request_body['params'][$parameter] = $value;
34
		}
35
 
36
		function request()
37
		{
38
			if(isset($this->api_request_body)) // We have params
39
			{
40
				curl_setopt($this->api_request, CURLOPT_POST, TRUE); //POST method since we'll be feeding params
41
				curl_setopt($this->api_request, CURLOPT_HTTPHEADER, Array('Content-type: application/yaml')); // Since we'll be using YAML
42
				curl_setopt($this->api_request, CURLOPT_POSTFIELDS, yaml_emit($this->api_request_body)); // Insert the parameters
43
			}
44
 
45
			// Now send the request and get the return on investment
46
			try
47
			{
48
				return yaml_parse(curl_exec($this->api_request)); // Pull the trigger and get nice pretty arrays of returned data
49
			}
50
			catch (HTTP_Request2_Exception $e)
51
			{
52
				echo 'Error: ' . $e->getMessage();
53
			}
54
		}
55
	}
56
?>
57

Update on 4Apr12 @ 1300EDT
I have updated the class to utilize JSON instead of YAML. Code change was actually pretty straight forward. It is shown below:

 PHP | 
 
 copy code |
?

01
02
<?php
03
	/*
04
	 * Author: Jason Gillman Jr.
05
	 * Description: This is my attempt at writing a PHP wrapper that will ease Storm API calls with PHP
06
	 * 				It will be designed to use the YAML format for talking with the API server.
07
	 * 				$api_method is as described in docs (Case matters)
08
	 * 				request() method returns an array generated from the API return
09
	 */
10
	class StormAPI
11
	{
12
		// Let's define attributes
13
		private $api_user, $api_pass, $base_url, $api_format, $api_full_uri, $api_request;
14
		private $api_request_body, $api_method, $api_params, $api_return; 
15
 
16
		function __construct($api_user, $api_pass, $api_method)
17
		{	
18
			$this->api_user = $api_user;
19
			$this->api_pass = $api_pass;
20
			$this->api_method = $api_method;
21
			$this->base_url = 'https://api.stormondemand.com/';
22
			$this->api_format = 'json';
23
 
24
			$this->api_full_uri = $this->base_url . $this->api_method . "." .$this->api_format;
25
			$this->api_request = curl_init($this->api_full_uri); // Instantiate
26
			curl_setopt($this->api_request, CURLOPT_RETURNTRANSFER, TRUE); // Don't dump directly to output
27
			curl_setopt($this->api_request, CURLOPT_SSL_VERIFYPEER, FALSE); // Apparently verification doesn't work with the API?
28
			curl_setopt($this->api_request, CURLOPT_USERPWD, "$this->api_user:$this->api_pass"); // Pass the creds
29
		}
30
 
31
		function add_param($parameter, $value)
32
		{
33
			$this->api_request_body['params'][$parameter] = $value;
34
		}
35
 
36
		function request()
37
		{
38
			if(isset($this->api_request_body)) // We have params
39
			{
40
				curl_setopt($this->api_request, CURLOPT_POST, TRUE); //POST method since we'll be feeding params
41
				curl_setopt($this->api_request, CURLOPT_HTTPHEADER, Array('Content-type: application/json')); // Since we'll be using JSON
42
				curl_setopt($this->api_request, CURLOPT_POSTFIELDS, json_encode($this->api_request_body)); // Insert the parameters
43
			}
44
 
45
			// Now send the request and get the return on investment
46
			try
47
			{
48
				return json_decode(curl_exec($this->api_request), TRUE); // Pull the trigger and get nice pretty arrays of returned data
49
			}
50
			catch (HTTP_Request2_Exception $e)
51
			{
52
				echo 'Error: ' . $e->getMessage();
53
			}
54
		}
55
	}
56
?>
57

10Mar/120

Creating a Gluster Back End on Storm Servers

As described in a previous article, Gluster is a good way to provide centralized storage for a load balanced cluster on Storm.

More below the fold

29Feb/120

Big Storage Smart Server

Have you needed a SmartServer with big storage, but didn't want to spend $500 for processor and memory you don't need?

Right now we have a couple i5-760 SmartServers with 4GB of RAM but 1.8TB of storage. These are perfect for those who just need place to store large amounts, whether using the server for serving the content itself, or as a form of network attached storage. These gems are only running for a cool $250. The closest thing that would give you 1.8TB of storage is gonna run you for $500

Want to run a big fat Gluster back end? These are the boxen to use!

And as always, if you have any questions, don't hesitate to give us a call at 800-580-4985.

6Feb/120

Load Balancing with Storm/SmartServers

One of the nice things about our cloud platform (Storm On Demand / Smart Servers) is the ability to easily provision load balancing between nodes. This can be used for a multitude of purposes, from increasing overall performance, to mitigating downtime due to server problems.

However, if you're considering going with a load balanced setup, there are a few key issues to be cognizant of.

More below the fold...

7Dec/112

Upgrading from Legacy VPS to Smart VPS

One thing that customers of our Legacy VPS product will have noticed is that CentOS 4 will be End Of Life come February 2012. While this doesn't mean that the server will stop working for them, it means that new patches will not be released, thus potentially exposing the customer to security vulnerabilities as they become known.

While this might cause some initial concern, the solution really isn't that hard. Upgrading to Liquid Web's Smart VPS and migration the data can be a relatively easy process!

1Aug/110

Slight hiatus

Well, there is going to bit of a hiatus on future posts here for a while. Well, that or a significantly spaced out time periods between posts.

I am a 25A (that's a Signal Officer) in the Michigan Army National Guard. I am currently down at my Officer Basic Course in Fort Gordon, Georgia for four months.

If during this time you would like to make suggestions for things you'd like to see, please submit a comment!

29Jul/110

Copying databases from one cPanel user to another

I was going through some of my tomboy notes and saw some PHP code that I cobbled together for a customer who needed to copy MySQL databases from one cPanel user to another.

I thought that it may be useful to others as well

 PHP | 
 
 copy code |
?

01
<?php
02
	// cPanel user you are copying data from
03
	$from_user = "fromuser";
04
	// cPanel user you are copying data to
05
	$to_user = "touser";
06
	// Some place to temporarilly story the SQL dump files
07
	$dumpdir = "/root/tempdbdump/";	
08
 
09
	// Add all the databases you need copied over to the array
10
	$dumpdb[] = "db1";
11
	$dumpdb[] = "db2";
12
	$dumpdb[] = "db3";
13
	$dumpdb[] = "db4";
14
	$dumpdb[] = "db5";
15
	$dumpdb[] = "db6";
16
 
17
	foreach($dumpdb as $database)
18
	{
19
		$dumpline = "mysqldump " .  $from_user . "_" . $database . " " . $dumpdir . $database .".sql";
20
		shell_exec($dumpline);
21
 
22
		$restoreline = "mysql " $to_user . "_" . $databasename " < " . $dumpdir . $database . ".sql";
23
		shell_exec($restoreline);
24
	}
25
?>

One thing to note is that I got lazy and didn't include code to delete the dump file after use, but that's a relatively simple task.

Tagged as: , , No Comments
27Jul/110

Complex Setups

One thing that many customers do is going with a more "complex setup" - a setup which involves things such as load balancing, separate database servers, etc. This allows for the mitigation of downtime given the inherent redundancy.

However there are many things that must be considered when looking at these more complex solutions. This includes software architecture, level of experience for the customer in running these setups, etc.

Liquid Web has a page that offers links to pre-configured solutions. For customers that know exactly what they need and how to setup their particular configuration, these links are a great way to quickly order the hardware.

However, for those who aren't quite sure of what they need, or need some assistance with configuring their setup, it is best to contact a Liquid Web sales engineer. The sales engineer will help determine a configuration that will work best for your needs.

For example, do you need your static content to instantaneously become available to all load balanced nodes? Do you upload content through a content management system such as WordPress (such as images or other files)? If so, then you would most likely want some kind of shared storage solution, such as our SAN. Do you manually upload content via FTP/sFTP and only need it pushed through the load balanced pool in non-realtime? Then an rsync solution would work fine from a master. The moral of the story (Aesop really ran a hosting company back in Ancient Greece) is that it is best to consult with one of our sales engineers to determine what solution is best for your hosting needs.

Filed under: Uncategorized No Comments
21Jul/112

StormOnDemand vs. SmartServers – Which one is right for you?

In a previous article, I presented a comparison between traditional dedicated servers and our cloud based dedicated servers.

However, there are further differences between Liquid Web SmartServers and StormOnDemand Baremetal.

Billing
One key difference between the two cloud services is how billing is broken down.

With Storm, billing is done hourly. SmartServers on the other hand use daily billing.

Bandwidth
Another key difference between the two cloud services is in how bandwidth is handled.

Storm by default using pay per gig pricing - $0.05/GB out. With that said, you can still purchase bandwidth bundles.

SmartVPS servers include 1,000GB In and 1,000GB Out. SmartServers on the other hand include 3,000GB In and 3,000GB Out in the price of the server, with the ability to purchase more bandwidth (again, only for the SmartServers, not SmartVPS).

Backup and Image Pricing
Pricing for backups and user images also differ between the two cloud products.

With Storm, backups are $0.10/GB/Month unless you buy a bundle, compared to SmartServers, which run $0.12/GB/month without a bundle.

For server image storage, Storm hits you for $0.15/GB/month and SmartServers charge $0.25/GB/month

Filed under: Uncategorized 2 Comments
20Jul/110

Traditional Dedicated v. Cloud Based Dedicated

One question that I get asked a bit is why someone would go with a Storm BareMetal or Liquid Web SmartServer as compared to a traditional dedicated server. The answer that I give to that question is that it really depends.

Traditional dedicated and cloud based dedicated servers each have their advantages over the other type. That is why it is important to determine what your architectural requirements are when deciding.

Advantages of Cloud Dedicated Servers (SmartServers/Storm BareMetal) over Traditional Dedicated

Quick Deployment and Granular Billing
One of the most apparent advantages with a cloud based server is the fact that they are pre-racked, and can thus be provisioned within minutes. This, combined with the fact that billing is done daily (SmartServers) or Hourly (Storm BareMetal), make cloud based servers ideal for developers who may need to kick instances quickly and for a relatively short amount of time for a project.

Dynamic Resizing
Another advantage of a cloud based server is the ability to dynamically resize an instance. This is certainly beneficial for long term upgrades, as the migrations are completely automatic and transparent to the user. However, users who have cyclic periods of increased usage can really benefit from this feature (again, combined with daily/hourly billing as well).

For example, I was working with a customer who currently has an older traditional dedicated server. On certain nights (which are known), his traffic literally doubles, which has caused problems for that server. In this case, we decided that a SmartServer was an excellent choice - prior to the start of the busy time, he upsizes the server to handle the significantly increased load, and then when the busy time is done, he just resizes down, only paying for the time that he used. It was truly a win/win, as the customer is able to handle the increased load as needed, while saving money.

Automated Advanced Networking
The advanced networking features of our cloud based servers are another significant advantage over traditional dedicated servers. Through the interface, or the Storm API, you can setup load balancing, firewall rules, and a private network. This makes it easy to transition from say a single server which is both hosting static web content as well as the database, to a frontend-backend setup where the two servers are linked via private networking, as no physical cabling needs to be run, nor switches setup.

Creating Server Images
With Liquid Web's cloud based servers, you have the ability to create server images, which you can subsequently use to kick additional instances.

For example, say that you were anticipating building site with a load balanced architecture. One thing that you might do is create a base configuration that all nodes would have, and then create an image. That way, additional node creation is simply an issue of using that image when they are created.

Advantages of Traditional Servers over Cloud Servers

Hardware Customization
One of the key advantages that a traditional server has over a cloud based one is that you are able to customize various hardware components much more. For example, it's easy to add additional hard drive space or RAM with a traditional server. However, with a cloud based server, you have to upgrade the whole instance. Much more granularity is allowed with a traditional dedicated.

Operating System Selection
Another advantage that traditional dedicated servers have over cloud servers is that, for now, selection is limited to what is available. With a traditional dedicated, any operating system can be installed. Be on the lookout over the next couple of months though for Windows on Storm and Liquid Web SmartServers. Update:Windows on Storm is now available, and should be available soon for SmartServers

Partitioning
One thing that traditional servers can do that our cloud servers can not do is have a custom partitioning scheme. Although the partitioning scheme that comes with Storm and SmartServers is adequate for many, some may require a more customized scheme.

Final Thoughts

As can be seen, choosing between a cloud based server or a traditional is based largely on what your requirements are. If you're looking at just kicking a Debian box to do some code testing on, our cloud offerings would be ideal given the speed of deployment and granular billing. However, if you need things like custom partitioning schemes or operating systems not currently offered with our cloud products, a traditional server would be the right choice.

Of course, Liquid Web sales engineers, such as myself, are around 24x7 to answer any further questions to may have, or to advise you on what the right solution would be for your hosting needs. Don't hesitate to contact us!

FireStats icon Powered by FireStats
Optimization WordPress Plugins & Solutions by W3 EDGE