Free Static Page Hosting on Google App Engine in a 5 minutes

Now-a-days we have a lot of options to deploy our applications. Some of them are Google App Engine, Google Compute Cloud, Amazon EC2, Heroku, Nodejitsu and much more. All the services have their advantages and disadvantages over others. Generally, we do not prefer much complex infrastructure or steps to deploy our static pages. Recently, I found that Google App engine has been a best platform for hosting our static web pages with decent free plan over other services. In this article, we will discuss a steps to host your static pages which can be personal blog, company site or even your client sites.

Create an application in Google App Engine

Visit Google App Engine and then create an application. When creating App engine application, the application id is very important. Because it acts as subdomain for your site. Lets say, application id is coolmoon, the site will be in

Install App Engine SDK for python

Since python has been a best supported language in App Engine, Download and Install App Engine SDK for python. Are you not a python developer(like me)? Do not worry, you do not need to write a single piece of python code.

You will use two commands from the SDK:  -  the development web server  -  for uploading your app to App Engine

Create an application folder

You have to create an application folder which has static files and configuration file to be deployed. The structure of the folder may be as follows

  - app.yaml              # configuration file. we will see in next section
  - public/               # public folder will contain static files
    - index.html
    - js/
    - css/
    - img/

Content of App Engine configuration(app.yaml)

  application: coolmoon
  version: 1
  runtime: python27
  api_version: 1
  threadsafe: yes


  - url: /(.+)
    static_files: public/\1
    upload: public/(.*)

  - url: /
    static_files: public/index.html
    upload: public/index.html

  - ^(.*/)?app\.yaml
  - ^(.*/)?app\.yml
  - ^(.*/)?#.*#
  - ^(.*/)?.*~
  - ^(.*/)?.*\.py[co]
  - ^(.*/)?.*/RCS/.*
  - ^(.*/)?\..*
  - ^(.*/)?tests$
  - ^(.*/)?test$
  - ^test/(.*/)?
  - ^README\..*
  - \.gitignore
  - ^\.git/.*
  - \.*\.lint$
  - ^fabfile\.py
  - ^testrunner\.py
  - ^grunt\.js
  - ^node_modules/(.*/)?

Test static pages

You can run development server locally and check your static pages by following command ./

Visit http://localhost:8080 to test your pages.


Everything is perfect and deploy the static pages. The command is used for deploy the application to Google App engine update .

It will ask for email and password of your Google account. The password must be application specific password. To know how to generate application specific password, please refer Application specific password.

You've made it

Finally you got your site hosted in <application-id> Static hosting is super easy with App Engine. Moreover it is faster than other static hosting services. Because it runs on Google infrastructure.

Happy static hosting and Have a nice day.

View comments

Things you should consider for MongoDB in production

We are using MongoDB for few of our products. We like to share some of the recommendations for MongoDB in production.

Handle Connection Errors

Few weeks before, we faced one weird problem in our NodeJS application. Our customer can view our site and not able to login into the application. We tried to figure out the issue and found that MongoDB database connection is broken during mid night. After that, our application is not crashed, but it is failed to connect MongoDB. We assume that it should auto reconnect if it is failed. But it does not happen. Finally we found that we did not handle error of MongoDB connection in our code.

You must handle error of MongoDB connection in you code. It can be even simple console log.

 mongoose.connection.on('error', console.error.bind(console, 'MongoDB connection error:'));

If you are using NodeJS, you must handle error and exception in all places. It is a best practice.

Setting Timeout

You have to properly set your timeouts. The driver's default timeouts are very aggressive ranges anywhere from 1 second (e.g. the Node.JS driver in some cases) to 30 seconds (e.g the Ruby driver), so you really need to think about what the optimal setting is for your use case.

For connections made through a Platform-as-a-Serivce (PaaS) such as Heroku, you might consider an even higher timeout (e.g. 30 seconds) since your application is likely running in a container that can be “idled” or “passivated” during periods of low activity

If you use Mongoose and NodeJS, then you can set connection timeout by

// Database connect options
var options = { replset: { socketOptions: { connectTimeoutMS : conf.dbTimeout }}};

// Establish Database connection
var conn = mongoose.connect(conf.dbURL, options);

MongoLab has written very good article on MongoDB Timeout

Connection Polling

You should consider using connection pooling. It will make for a much faster and more stable application. You won't spend the time on each request to create connections (can be noticeable to the end user) and you aren't subject to connect errors either.

The mongoose package for NodeJS handles connection pooling by default. If you use your own MongoDB driver, make sure you have implemented connection pooling.

Thanks to MongoLab for sharing amazing tips of MongoDB with us. The support of MongoLab is awesome and respond for questions very quickly. I highly recommending for MongoDB database.

Have a nice day.

View comments

Dropbox will save your head

Recently My Mac OSX has been crashed and somehow i cannot retrieve some of my data from hard drive. But i am fortunate that i have already synced important folder to the Dropbox that saves my head.

Few days ago, i got a tweet from my favorite Github contributor tj (Creator of ExpressJs, Jade, Mocha)

I am really sad about it. It can happen to anyone. So, whenever you started working on project(Pre-Github), You should consider sync to the Dropbox. Moreover it is always better and safer to sync important folder and files. It can be simply done by creating symbolic link to the folder in the Dropbox.

Open terminal and do the following

## Go to dropbox folder. It can be any dropbox folder
cd ~/Dropbox/MacOSX

# Create symbolic link to Stickies database
ln -sf ~/Library/StickiesDatabase .

# Create symbolic link to Sublime text User data
ln -sf ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User Sublime3-User

In symbolic link creation, you can use .(dot) in the last argument to use same folder or file name as original. Otherwise you can specify the name that you wanted to have in your Dropbox.

Have a nice day.

View comments