All posts by PF

YET another Cloud vs Dedicated vs Colocation comparison

SUMMARY: The answer will surprise you. Colocation can be a much better option than cloud for certain types of applications. Read on to see why

Colocation, which means buying your own hardware up front and running and managing it in a third-party site,  is not usually seen as a cheaper alternative to cloud. But, oddly enough, it can be.

Last week I compared cloud instances against dedicated servers showing that for long running uses such as databases, it’s significantly cheaper if you go with dedicated servers, but that’s not the end of it. Since you are still paying for those server resources every month, if you project the costs out 1 or 3 years, you end up paying much more than if you had just bought the hardware outright. This is where buying your own hardware and colocating it becomes a better option.

Continuing the comparison with the same specs for a long running database instance, If we price a basic Dell R415 with x2 processors each with 8 cores, 32GB RAM, a 500GB SATA system drive and a 400GB SSD, then the one-time list price is around $4000 – more than half the price of the SoftLayer server at $9,468/year we came up with in our previous analysis.

Remember, again, that this is a database server so while with Rackspace, Amazon and SoftLayer you pay that price every year, after the first year with colocation the annual cost drops to $1932 because you already own the hardware. Further, the hardware can also be considered an asset which has tax benefits.

Source: http://gigaom.com/2013/12/07/want-to-reduce-your-cloud-costs-70-percent-heres-how/

Add or edit a post to wordpress with PHP

Since 2010 that I’m using this script to post content on some of my 10s blogs.
I got it from WORDPRESS XMLRPC – POSTING CONTENT FROM OUTSIDE WORDPRESS ADMIN.

Add a post to wordpress with PHP

<?php

require_once("IXR_Library.php.inc");
$client->debug = true; //Set it to false in Production Environment

$title="Blog Title"; // $title variable will insert your blog title
$body="Blog Content"; // $body will insert your blog content (article content)
$category="category1, category2"; // Comma seperated pre existing categories. Ensure that these categories exists in your blog.
$keywords="keyword1, keyword2, keyword3";
$customfields=array('key'=>'Author-bio', 'value'=>'Autor Bio Here'); // Insert your custom values like this in Key, Value format

$title = htmlentities($title,ENT_NOQUOTES,$encoding);
$keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);

$content = array(
'title'=>$title,
'description'=>$body,
'mt_allow_comments'=>0, // 1 to allow comments
'mt_allow_pings'=>0, // 1 to allow trackbacks
'post_type'=>'post',
'mt_keywords'=>$keywords,
'categories'=>array($category),
'custom_fields' => array($customfields)
);

// Create the client object
$client = new IXR_Client('Your Blog Path/xmlrpc.php');
$username = "USERNAME";
$password = "PASSWORD";

$params = array(0,$username,$password,$content,true); // Last parameter is 'true' which means post immediately, to save as draft set it as 'false'

// Run a query for PHP if (!$client->query('metaWeblog.newPost', $params)) {
die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
} else { echo "Article Posted Successfully"; } ?>

Edit a post in wordpress with PHP

Continue reading Add or edit a post to wordpress with PHP

NSA’s ANT Division Catalog of Exploits for Nearly Every Major Software/Hardware/Firmware

After years of speculation that electronics can be accessed by intelligence agencies through a back door, an internal NSA catalog reveals that such methods already exist for numerous end-user devices.

(…)

A document viewed by SPIEGEL resembling a product catalog reveals that an NSA division called ANT has burrowed its way into nearly all the security architecture made by the major players in the industryincluding American global market leader Cisco and its Chinese competitor Huawei, but also producers of mass-market goods, such as US computer-maker Dell and Apple’s iPhoneSee: Cisco / Dell /Apple Comments Re: NSA Backdoors

Read more at http://leaksource.wordpress.com/2013/12/30/nsas-ant-division-catalog-of-exploits-for-nearly-every-major-software-hardware-firmware/

 

HipHop-Vagrant-VM

HipHop for PHP (shortened as HipHop) describes a series of PHP execution engines and improvements created by Facebook. The original motivation of HipHop was to save resources on Facebook servers, given the large PHP codebase of facebook.com. As development of HipHop progressed, it was realized that HipHop could substantially increase the speed of PHP applications in general. Increases in web page generation throughput by factors of up to 6 have been observed over Zend PHP.

Source: http://en.wikipedia.org/wiki/HipHop_for_PHP

 

Setup a test environment for HipHop VM.
The final VM will contain HHVM, Nginx, PHP, MySQL, ab.

Some graphs comparing PHP 5.3, PHP 5.5 and HHVM.
https://blog.liip.ch/archive/2013/10/29/hhvm-and-symfony2.html

Stackoverflow – lessons learned

Lessons Learned

This is a mix of lessons taken from Jeff and Joel and comments from their posts.

  • If you’re comfortable managing servers then buy them. The two biggest problems with renting costs were:
    1) the insane cost of memory and disk upgrades
    2) the fact that they [hosting providers] really couldn’t manage anything.

  • Make larger one time up front investments to avoid recurring monthly costs which are more expensive in the long term.

  • Update all network drivers. Performance went from 2x slower to 2x faster.

  • Upgrading to 48GB RAM required upgrading MS Enterprise edition.

  • Memory is incredibly cheap. Max it out for almost free performance. At Dell, for example, upgrading from 4G memory to 128G is $4378.

  • Stack Overflow copied a key part of the Wikipedia database design. This turned out to be a mistake which will need massive and painful database refactoring to fix. The refactorings will be to avoid excessive joins in a lot of key queries. This is the key lesson from giant multi-terabyte table schemas (like Google’s BigTable) which are completely join-free. This is significant because Stack Overflow’s database is almost completely in RAM and the joins still exact too high a cost.

  • CPU speed is surprisingly important to the database server. Going from 1.86 GHz, to 2.5 GHz, to 3.5 GHz CPUs causes an almost linear improvement in typical query times. The exception is queries which don’t fit in memory.

  • When renting hardware nobody pays list price for RAM upgrades unless you are on a month-to-month contract.

  • The bottleneck is the database 90% of the time.

  • At low server volume, the key cost driver is not rackspace, power, bandwidth, servers, or software; it is NETWORKING EQUIPMENT. You need a gigabit network between your DB and Web tiers. Between the cloud and your web server, you need firewall, routing, and VPN devices. The moment you add a second web server, you also need a load balancing appliance. The upfront cost of these devices can easily be 2x the cost of a handful of servers.

  • EC2 is for scaling horizontally, that is you can split up your work across many machines (a good idea if you want to be able to scale). It makes even more sense if you need to be able to scale on demand (add and remove machines as load increases / decreases).

  • Scaling out is only frictionless when you use open source software. Otherwise scaling up means paying less for licenses and a lot more for hardware, while scaling out means paying less for the hardware, and a whole lot more for licenses.

  • RAID-10 is awesome in a heavy read/write database workload.

  • Separate application and database duties so each can scale independently of the other. Databases scale up and the applications scale out.

  • Applications should keep state in the database so they scale horizontally by adding more servers.

  • The problem with a scale up strategy is a lack of redundancy. A cluster ads more reliability, but is very expensive when the individual machines are expensive.

  • Few applications can scale linearly with the number of processors. Locks will be taken which serializes processing and ends up reducing the effectiveness of your Big Iron.

  • With larger form factors like 7U power and cooling become critical issues. Using something between 1U and 7U might be easier to make work in your data center.

  • As you add more and more database servers the SQL Server license costs can be outrageous. So by starting scale up and gradually going scale out with non-open source software you can be in a world of financial hurt.

    Copied from http://highscalability.com/blog/2009/8/5/stack-overflow-architecture.html

 

 

CodeIgniter – subqueries

On my latest work/project, with CodeIgniter, I need to use subqueries – a select inside another select.

This is a subquery library for CodeIgniter’s active record class. It lets you use active record methods to create subqueries in SQL queries. It supports SELECT, JOIN, FROM (and other statements, I guess). It also supports subqueries inside subqueries.
From: https://github.com/EllisLab/CodeIgniter/wiki/Subqueries

For that I had to download a subquery library for CodeIgniter’s available where
https://github.com/NTICompass/CodeIgniter-Subqueries.