Saturday, November 28, 2009

What If Hosting Was a Library?

# Was thinking, "if hosting was a library, what might it look like..."

require 'ProviderX'

# We'll pretend we already have an account with fictitious ProviderX

host = ProviderX.new(:user => 'foo', :password => 'secret')

# Let's see what ProviderX will allow us to deploy to

host.provides
> ['Amazon', 'Google']

# Let's create a new environment to deploy to

production = host.cloud.new(:vendor => 'Amazon', :name => 'production', :min_cpu => 2, :min_mem => 1024)

# We also would need to define the application that we wish to deploy

application = host.application.new(:repository => 'http://foo.com/foo.git', :type => 'Rails', :name => 'foo', :domain => 'foo.com', :ssl_enabled => true)

# All set! Let's deploy.

application.deploy_to production

application.deployed?
> true

application.deployed_to
> ['production']

production.applications
> ['foo']

# Maybe we forgot that we want to redirect www.foo.com to foo.com

application.redirects.add :from => 'www.foo.com', :to => 'foo.com'

# We don't want to deploy the code again, we just want to sync configuration changes (the redirect).

application.sync_configs production

# Perhaps we could control our resources from within our application

if production.swapping?
  production.ram.add 128
end

# That's it for my day-dreaming.

5 comments:

  1. The vendors should just conform to the host interface. Less typing, more explicit.

    production = Amazon::Cloud.new(blah blah)

    Honestly, I've learned to live without stuff like Capistrano though and realized my life is simpler for it. Shell scripts FTW. :-)

    ReplyDelete
  2. IMO there should be an application system requirements protocol and a language which supports declarative programming as a first class citizen like Ruby should be able to describe the system requirements of the application down to every detail and be transaction focused. This way we can describe the performance for each transaction within the application and also the resource consumption of the application and have the cloud host digest these requirements and use their intelligent systems to spawn a system to support the application requirements. Then of course learn the behavior of the application over time and autotune that shit.

    ReplyDelete
  3. A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. hosting chile

    ReplyDelete
  4. You have a great sense of writing I must say. Your post has those facts which are not accessible from anywhere else. It’s my humble request to u please keep writing such remarkable articles hostgator penny

    ReplyDelete
  5. Even the most professional people will tell you that themselves. Because your needs will grow as the number of visitors to your website increases, you will know all about it as you go along.

    Magento Hosting

    ReplyDelete