AdKeeper Raises $35 million in second round funding!

Jan 03
2011

I joined AdKeeper several months ago – it’s so far been a blast, and has really nailed the startup-junkie sweet spot in me! With a press announcement today, it just got a lot more interesting…

As we pound out our goals and deadlines on the code-front, where I dwell, the rest of the company has been hard at work refining the vision and pushing the marketing. Today we announced our second round funding, a whopping $35 million, led by Oak Investment Partners – bringing the total raised to $43 million.

So, I get this question alot, in fact, my sister just asked me last night: “What are you guys building, Chris?”. Lets save your eyes, and give you a fun video this time:





By the way, my sister’s response via phone was “I save ads all the time, I just usually book mark them and look for them later, but this makes it easier – I really think people will use this”. I feel the same way!

You can also find out more at www.adkeeper.com.

You can also watch more videos (Q&As, fun commercials, and more) at our YouTube channel: http://www.youtube.com/user/TheAdKeeper

Apache Low Memory Settings + PHP + APC

Apr 03
2010

In addition to moving my servers to save costs, I ran into a two part issue that I lumped into: “I need to tune memory usage a bit”.

Part 1: Apache

Since I moved my Apache servers to lower memory instances, I was running into swap space usage that I could easily avoid, ie:

free -m
                      total       used       free     shared    buffers     cached
Mem:               268        245         22          0         71         53
-/+ buffers/cache:        120        147
Swap:               511         29        482

Some of the reasoning behind this was that, by default, Apache expects a bit more memory to be available than what I provided to it in the move. The fix was to introduce a few settings to lower child processes and limit concurrent connections to something more reasonable to the type of traffic my site really gets – which is near nothing most days.

The settings I dropped into apache were:

httpd.conf:

    #Low Memory Settings
    StartServers 1
    MinSpareServers 4
    MaxSpareServers 2
    ServerLimit 6
    MaxClients 6
    MaxRequestsPerChild 3000

I made the adjustments, cleared out the swap space with:

swapoff -a
swapon -a

Then restarted apache:

/etc/init.d/apache2 stop
/etc/init.d/apache2 start

And all was well in the world.

free -m
                       total       used       free     shared    buffers     cached
Mem:                268        207         60          0         31         79
-/+ buffers/cache:           97        170
Swap:                 511          0        511

Part 2-1: PHP

A bit simpler, my blog site was running into max memory allocation limits. I had left the default php.ini in place in the upgrade, so I needed to do a once over of configs and change memory_limit from 16M to something more reasonable for my site.

php.ini

memory_limit = 64M      ; Maximum amount of memory a script may consume (16MB)

Part 2-2: APC

Having Apache settings set for lower memory usage also allowed me more room to increase my APC cache limit a bit higher to keep more pages faster. From 30 MB to 50 MB.

apc.ini

extension=apc.so
apc.enabled=1
apc.shm_size=50

Other obvious solutions in consideration, switch to Rackspace to invert my memory/cpu requirement/cost ratios. Any other tips are welcome :-)

Mysql: Force Localhost to Use TCP, Not a Unix Socket File

Apr 03
2010

So, recently I decided I was paying too much for my server because I was not maximizing performance across all the various daemons. So I decided to split my larger server into a handful of smaller servers to be able to fine tune each one to dedicated purposes. All went well, but I had some trouble for a few evenings figuring out how I could port forward localhost:3306 to the, now remote, database server. This should have been dirt simple with an iptables rule – but after digging in, I discovered MySQL treats localhost “special” by sending connections through the unix socket file, which is absolutely faster, but only works if the database daemon is on the same host as the connecting application.

After doing some research, I found it is possible to use a tool like socat and autossh to wrap an ssh tunnel to forward connections through the socket file to a remote IP over TCP. This however, was more complex and one off than I cared to explore for my simple problem. I finally resorted to using DNS and to stop using localhost as the host name. However, a few tid bits for the weary traveler:

  • The mysql client library is responsible for selecting the protocol.
  • PHP’s internal mysql libraries, unfortunately, as far as I could discover ( please correct me if I am wrong here ), do not allow you to select the protocol.
  • So if you’re using “localhost” as your host name in a PHP mysql_connect, you’re forced to go through the socket file, however, you can use 127.0.0.1 instead of localhost to force TCP.
  • The linux mysql-client package command line tool offers a –protocol=tcp flag if you want to force TCP. You can also set this as a default inside /etc/mysql/my.cnf under the [client] heading

my.cnf:

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
protocol        = TCP

Again, this appears to work fine if you’re not using PHP as your client.

I hope this lesson learned ( use DNS ) comes as a helping hand to others out there. If anybody has some other suggestions, please do leave a comment!

Upgrading from PHP 5.2 to 5.3 in Ubuntu – Part 1

Jul 05
2009

( I’m publishing this partially done so that it acts as a reminder for me to FINISH it… bare with me! )

Overview of Important Changes

variable class naming

Previously in PHP, only method and function names could be variables.  Ie:

$func = "print";
$func("Hello World");
class Foo {
  public static function Bar()
  {
     echo "Hello World";
  }
}

$method = "Bar";
Foo::$method();

Now, in PHP 5.3+, variable class naming is also supported – making possible this syntax:

class Foo {
  public static function Bar()
  {
     echo "Hello World";
  }
}

$class = "Foo";
$method = "Bar";
$class::$method

This new class variable naming should provide a much desired level of ambiguity for PHP developers, I know for my MVC framework, it could really change the Typhoon PHP Typhoon->run() method in a positive way.

late static binding

This is a more advance PHP OOP topic – that almost came off as a bug in previous versions of PHP. I’ve personally ran into it myself on occasion, and am happy to see a solution available in PHP 5.3. In previous versions of PHP, static calls resolved to the inherited class. In cases where one needed a static call to resolve in it’s own scope, unexpected results were common. Ie:

class Foo {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        self::who();
    }
}

class Bar extends Foo {
    public static function who() {
         echo __CLASS__;
    }
}

Bar::test();

Output:

Foo

The solution, “Late Static Bindings”, solves this using the static keyword:

class Foo {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        static::who();
    }
}

class Bar extends Foo {
    public static function who() {
         echo __CLASS__;
    }
}

Bar::test();

The static keyword resolves to the calling class and produces the expected output:

Bar

Additions to Standard PHP Library (SPL)

Circular Garbage Collection

Lambda Functions (Anonymous Functions)

Closures

Overriding Internal Functions

New Reserved Words

Namespaces

Jump Labels

Changes to Functions and Methods

Extensions

Phar

php.ini Changes

Deprecated Methods

Install php 5.3 on Ubuntu

mkdir download && cd download
wget http://snaps.php.net/php5.3-200906131830.tar.gz

Choosing the best platform for the job: CMS Solution, PHP MVC, Django, or Ruby on Rails

May 14
2009

I see this all the time:  “I’m building a website, but I don’t know what the best technology to use is?  This guy says PHP,  that guy says Ruby.  What’s better?”.  While there are definitely a handful of developers that will quickly jump to share my point, there are far too many that have biases for certain technologies and will quickly defend them with a bullet list.  Avoid those guys with biases – their tool belts are smaller.

Some things to Consider

Choosing the best technology really depends on what it has to do.  You wouldn’t hit a screw with a hammer?  Well, you can… but you shouldn’t.  Choose your website technologies based on what it has to do and what it takes to create and support it.  Some things to consider:

  • Budget and Market Cost
  • Continued Support and Development
  • Scalability – meaning, when new problems arise, will the solution be able to meet and defeat those problems?
  • Demographics – how well does the workforce powering your technology cater to your product’s needs?

Simple Sites

Say, perhaps, you want to build a small website to advertise a product or yourself.  It needs a few dynamic options, like a contact form, and maybe a shopping cart. I highly recommend exhausting service oriented solutions before going custom.

You could quickly find a web developer, blow a few hundred bucks, spend several weeks customizing and tweaking, and there you have it – no real support, you may or may not have a scalable back-end to manage it, and future expansions become expensive.  Or…

You could throw up a wordpress.com site for your landing page, link it to an inexpensive shopping cart service like e-junkie.com, and have significantly more bang for FREE by gaining access to thousands of plug-n-play plug-ins to extend your site with gallery applications, feeds, sharing tools, SEO management tools, as well as all the support of a service like e-junkie on call for your every e-commerce need.

See where I’m going with this?

More Complex Project

Lets envision you need something more complex than a personal page.  How about, a niche social network?  You want your own version of Myspace, and white label solutions just don’t have what it takes.  So you’ve raised thousands of dollars in angel investment, got your business plan, and are perplexed by the question of this post, “What technology?!?!”.  In this case, I would suggest considering the labor force and scalability behind each technology in correlation to what that is going to mean for your budget.

PHP Frameworks

While PHP has a huge work force, and many success stories, the language itself is rather controversial, as are philosophical differences in it’s “thousands” of frameworks.   A handful of frameworks are well-known, such as Symfony, CakePHP, Zend, CodeIgniter, KohanaPHP; though being an expert level PHP developer, I can tell you that many of the PHP frameworks, well, quite frankly, suck.  It’s new and easy to learn, and bloated with newbies making decent money, but not deploying consistent theory or solid code.  This is not always their fault, PHP lacks as a new language.

PHP also brings a lack of legacy support with each new version.  Consider the lifespan and size of your project.  Does this site need to run code for several years?  How difficult might it be to migrate old code to new versions of the language as they are released?  Just an example:  When  PHP5 released, it left thousands of web hosts outdated and incapable of updating without major financial and time expense due to the fact that PHP5 had changed syntax to introduce OOP, which broke PHP4.  To simply upgrade to PHP5 would break millions of websites without those webmasters first learning the changes in the language and making updates to their scripts.  Such scenario meant serious problems for web hosts that wanted to support latest technologies for new clients while maintaining legacy technology for existing clients.  PHP6 bodes better, but will still admittedly face similar problems.

As for the workforce, it’s just too easy to get into PHP.  The skill level required to create a PHP site is significantly less than that of other languages.  It’s the nature of PHP – Hypertext Pre-Processor, which, to many, is code (pun intended) for HTML on steroids.  Your average MySpace fanatic knows a bit of HTML these days, PHP is just the next informal step for many.  If you can find a skilled Object Oriented Programmer (OOP) – you’re well off, but the work force powering PHP is predominately less read into computer science theory and less likely to deploy best practices.  Why should they? – that’s all part of the beauty of the language.

Not to say a quality website can’t be developed in PHP, but I haven’t worked with any particular PHP Framework that really nailed it for me as a perfectionist.  You’ll find many like me in the PHP work force:  “just another php framework author”.  There seems to be an abundant number of us that find it difficult to produce quality code in popular frameworks, causing us to resort to building our own.  Mine is coined Typhoon.

Though, don’t get me wrong, I LOVE PHP and have developed numerous websites in the language.  I also look forward to the great new benefits in Version 6.  When you come down to picking PHP for your choice as a platform tool, just be sure the scope of your project is small to medium sized, speed of development being important, and ongoing support of the project being minimal.  Past that, the coding standards recognized by the PHP community are just too flexible and inconsistent for me to feel comfortable  spending significant time and expense on a bigger PHP site.

Django

“Developed four years ago by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.” – from the creators of the Django Project

Now Django is a cool framework built in the Python language, and perhaps the premier web framework of Python. Unlike PHP, Python is a general utility language. It’s usage can be found in many aspects of computer science from desktop applications, to video games, to web development – and it has been around awhile.

Lets keep in mind the quote above though.  It was developed by-and-for the newsroom.  As such, it caters VERY well to companies that have a similar infrastructure.  While you can develop many applications regardless, that fundamental purpose gives the framework an overall flavor that may not be quite as flexible in every problem domain.

The built in content management system (CMS) feature of Django is really quite a gem.  It’s effective at allowing developers to rapidly generate applications for non-technical people to manage.  Would I use it for a social network?  Probably not as my first pick.  Would I use it for news syndication site?  Hell yes.

Python has been around since the early 90′s and has had sufficient time to incorporate advanced computer science theory and stabilize.   The workforce powering Django applications is also significantly more well-read than the PHP workforce ( I say this loosely, of course ), as the Pythoon workforce has been around longer in general.

Django can sleep safe at night knowing it was built on a stable language that doesn’t anticipate significant change year after year, making it a great platform for websites requiring long term support and development.

Ruby on Rails ( Soon to merge with MERB in Rails 3 )

Talk about some BUZZ!  I’ll admit I did not want to learn Ruby on Rails at first.  I love learning technology, but when Rails was just gaining it’s hype, I was getting deep into PHP and tended to stay in the PHP world.  Mistake at the time, on my part.

Rails identifies itself as a “web framework”.  Unlike Django, Ruby on Rails was developed to tackle many more of the standard problems developers face on a much broader sense of web development.  This by itself should not be translated as “Rails is the creme de la creme” for your web project, but it does make it a strong candidate to initially consider.

When to Consider Rails

  • You have a project with many developers, possibly several contractors that will come and go as needed.
  • You need fast scalability and flexibility due to a multi-faceted problem domain, ie:  niche social networks tend to start simple and then tack on lots of complex features.

Some Pros

In terms of computer science, 9.9999 times out of 10, problems we face in development are problems we’ve answered time and time again, either in theory or practice.  Thankfully, the Rails community innately conforms to the DRY Principle ( don’t-repeat-yourself ).  The community also drastically alleviates extra invention faced by developers, simply by embracing, building upon, and reinforcing community accepted solutions.  The now famous Rails motto:  “Convention over Configuration” sets a tone where the community expects eachother to follow a standard set of approaches versus relying on the individual’s limited resources to reach the same conclusions others have already reached.

Not only is it a motto, it’s an obstacle for “do-it-my-way” programmers, as it’s rather difficult to make a Rails application without doing it the “Rails way” – things will just not go smoothly if you attempt to break standards.  As developers tend to think differently about the same problem domain, Rails lends itself as a great framework to conform the result of their different approaches to the same represented solution.  In identifying conventions and standards, developers of the rails community spend significantly less time “re-inventing the wheel”, and more time knocking out features and drinking beer.

Some Cons

It’s memory intensive/innefficient.  MERB is merging with Rails 3 – which promises to improve performance, though in the meantime, I have several Rails applications running for small sites where I should have deployed PHP, I’m noticing I’m low on memory due to such, which ultimately costs me more money to keep my servers up to par with my Rails demands.

Windows users tend to have a more difficult time with Rails whereas the PHP community has gone through a few more lengths to make development in windows fairly painless.  Rails is significantly is better to develop on unix-based platforms, like Linux and Mac.  Windows users will need to go through extra hoops to keep up with dependencies largely created and maintained by the unix-based users – though, if you’re a serious web programmer using windows as your primary platform, you should consider weening off sooner than later anyways.

Rails isn’t THAT light weight.  It incorporates a lot of functionality and sub framework patterns that you just may never use on some projects.  Again, Rails 3 promises to improve in this area as well.

[Conclusion Pending]

Generate any HTML tag with these two functions.

Apr 05
2008

I was working on a form generation API on Typhoon PHP Framework today and came up with two wonderful functions for generating any HTML tag using PHP.

Here are the functions, enjoy!:

public static function tag($element, $attributes = array()) {
    $buffer = '<' . $element;

    foreach($attributes as $key => $val) {
        $buffer .= ' ' . $key . '="' . $val . '"';
    }
    $buffer .= '/>';

    return $buffer;
}

public static function blocktag($element, $attributes = array()) {
    $content = $attributes['content'];
    unset($attributes['content']);

    $buffer = '<' . $element;
    foreach($attributes as $key => $val) {
        $buffer .= ' ' . $key . '="' . $val . '"';
    }
    $buffer .= '>';

    $buffer .= $content;
    $buffer .= '</' . $element . '>';

    return $buffer;
}

Currently I use these in conjunction with Smarty helpers to create consistent markup across a project I’m working on. Any thoughts are appreciated!

Visit Other Sites!

Find me on other sites...

Archives

All entries, chronologically...

Pages List

General info about this site...