Author: Matt

  • Migrating from Apache to Nginx + Gunicorn

    I was never really sure why people opted to swap out the heavily tested, widely deployed Apache web server for alternatives other than those trying to eek out a little bit more performance.  Finally I found a good reason to change my setup.

    When trying to enable Celery for asynchronous tasks on my web server I ran into some unexpected errors with imports.  Eventually I tracked the problem down to mod_wsgi was compiled and running against an old version of Python rather than the newer version in the apps virtualenv.

    The bigger problem with Apache outside of any performance issues is the coupling of Apache, mod_wsgi and python.  Upgrading python becomes complex and running multiple django apps on different versions of Python is non-trivial.  The other issue I found is that Apache takes several minutes to reload which is enough time to disrupt users.

    Nginx acts as a trivial reverse proxy.  Once it’s configured and running it will probably never need to be restarted.  It directs incoming requests to a free standing python application that is running and listening at localhost:8000.  Gunicorn is used to run the django app on port 8000.  It can be run from the command-line all within the virtualenv’s copy of python and gunicorn.  This way the django app is nicely isolated and it operates without tying itself to too much of the OS.

    Making the gunicorn process a daemon so that it runs in the background and starts after a system reboot is handled by having Supervisor running.

    The real day to day benefits to getting rid of Apache is that deployments are faster and there’s less downtime when restarting the server.  It also gives more flexibility for upgrading python rather than using the system installed version.  In the end it was easier to switch to Nginx + Gunicorn + Supervisor rather than fixing the Apache config to work with Python 2.7.3

  • Biting Off More Than You Can Chew

    If there is one fault that I have it is that I continually make ambitious plans and take on every little project that someone suggests.  The big iOS game that I was working on for the last month is looking like it’s too much for one person to complete in a reasonable amount of time.

    Lesson learned:  If a company of 50 is developing an application and it takes them 6 months to complete then it will not be possible to do something similar on my own in half the time.

    God.  That is actually hard to admit.

    So the big project is going in storage for a while and I will focus on smaller deliverables.  More easy to build games and build up the infrastructure, code libraries, and cross-promotion network of apps needed to push a good game to higher heights.

    There are two factors I have found to being able to be productive:

    1. Setting small goals and short timelines seems to be the best way for me to make progress on things.  I love to ship products and updates.  Give me just a handful of features to add to an application and I’ll be able to hammer it out quickly and deliver the update.  Too big of a change makes me nervous that I’m going to break too many things.
    2. Headphones.  Removing distractions and getting into the zone with my code is crucial.  With the headphones on I can work for hours without getting distracted by people or what might be on TV.  It’s amazing how often you forget to go to bed or eat when you can maintain your focus on the task at hand.
  • UFO Invader Fun Facts

    Since launching the game in September 2011.

    27,049 Users have played started the game 107,276 times.

    They’ve played 501,609 games.  Purchased 3,103 continues, and 4,719 upgrades.

    Players have spent real money 468 times to buy in the game currency.

    The average length of time someone plays the game for is 5.8 minutes.

    34% of players are in the USA.

    24% of players are in China.

  • UFO Invader Update Coming

    main menu mockup

    The first game I did for iPhone was released back in 2011. Seems like eons ago. The game hasn’t been updated, or promoted since that initial release and yet there are still an average of 100 people playing it every day.

    I’m working with Colum on a strategy to launch a bunch of new games over the next several months starting with an update to the code for UFO Invader.

    The new update will include many of the things I’ve learned in the last 15 months from selling my apps on the store. It should be able to improve monetization, make the game more fun, and I’ll be adding a bunch of new upgrades to the game so that players have new things to collect and buy with the in game currency.

    Much of the weekend was spent just getting the app to compile again. Now that it’s running again on my iPad there’s a lot of graphics work to do to get the app working with all the retina devices that have come out since it was originally released.

    I’m excited to see how this game update does and then to move on to creating a bunch of new games in the coming months to hopefully re-launch the Halotis brand.

  • Bone Spur

    So looks like I have a small bone spur on my heel. not a big deal, but glad I know now what to do about it.

    For the next month I’ll be doing a lot of stretches and icing it. Hopefully that will get things back to normal and I can start running more often.

  • Playing With Node.js

    When exploring ways to build a good chat server there are an overwhelming number of options.

    The old way of doing things with polling the server for new messages was simply not an option but the alternatives are a little scary.  Using a SQL database seemed a bit overkill for just posting messages.

    In the python world the asychronous server options which would support either raw sockets or websockets include Tornado, Twisted, and gevent.  The other option was to try out Node.js.

    Chat servers seem to be the de-facto example app for these types of server frameworks.  Yet unfortunately there are very few full featured examples to be found.

    I initially wrote a chat server that worked with raw sockets using Twisted.  However, testing the raw socket solution proved annoying, and creating a web based admin for the chat server would require yet another service to convert the raw socket into a websocket or develop a native client app for communicating to the server.

    So I took a step back and started again with Node.js.  Node.js with socket.io proved to be quite a bit simpler to code than the raw sockets on Twisted option.  Using websockets will add a requirement on my iOS client for a library, but it makes things much easier to test through a html client.

    For the persistence backend there are also many different options.  I have an existing MySQL server that I could have used, but I was interested in trying something a bit leaner.  Both Redis and MongoDB stood out.  At the moment I’m still evaluating which backend to use.

    So it’s not quite finished enough to share the code.  I’ll put it up on github when it’s finished.

  • Foot X-Ray

    It’s long overdue but I finally accepted that I can’t fix my bum ankle problem without seeing someone about it. It’s an old injury from doing a half-marathon on not enough training. I went to see a foot specialist in late December and got a referral to get an x-ray done on my foot. It’s the first time I’ve seen a doctor for anything in over a decade and the first time I’ve had to go to a hospital (for the x-ray) since I was a kid.

    The followup is next week and I’m curious to find out what might be going on under the skin. Hopefully something can be done.

  • Going to be a Great Year

    I have a feeling that 2013 is going to be a great year. A real turning point.

    My achievement goals for the year is to create a top notch Farmville type game for iOS and to do a kitchen renovation. This year there is a real potential for my businesses to take off and give me the chance/money to upgrade the kitchen.

    My fitness goal for the year is to get in a routine for lifting weights and make some steady progress on improving my max lifts. Perhaps a gym membership is in order. Since hitting 30 I definitely am starting to notice that things take longer to heal and I want to be one of those energetic 40 year olds who does downhill mountain biking, skydives and can still take big air on skis. A focus this year on building general strength should be a good base for the future.

    My educational goal for the year is to learn how to delegate and manage teams. Something I’ve never been good at and is required for me to take my businesses to the next level. I’m not entirely sure how to learn this other than by hiring some people and just jumping into it.

    I can’t put my finger on it but for 2013 so many things are on the cusp of a tipping point that it’s hard to imagine this not being a great year.

  • What to do with a Raspberry Pi

    I’m trying to think of some ideas for what to do with a Raspberry Pi.

    There’s just so many things that people have done with these little $35 computers that it is overwhelming to think of what to do with one.

    Here’s a list of ideas I’ve scoured from the web:

    • Webcam server
    • Vehicle tracking (using an add-on GPS module)
    • Streaming internet radio box
    • Vehicle Diagnostics, full OBDII logger with touch screen interface
    • Baby monitor
    • Media server by adding a couple of USB hard drives
    • Media receiver (hopefully we’ll get a port of XBMC or PLEX)
    • Video chat
    • Game emulator, running MAME (build your own arcade cabinet?)
    • Network Attached Storage setup (NAS)
    • Mini web server
    • FTP server
    • Proxy server
    • Print server
    • Firewall
    • Portable Media PC
    • Run an alarm system
    • Security webcam (with motion sensor)
    • Control garden lighting
    • Control sprinkler system
    • Wearable computer
    • HTPC for TV web browsing
    • HTPC for streaming Netfilx / Hulu etc
    • In car Computer
    • Thin client computer
    • Game server
    • IRC / chat server
    • build a cheap laptop
    • build a cheap tablet
    • create a digital photo frame
    • Asterisk VOIP server
    • PBX
    • Home automation system
    • MP3 player
    • Portable personal computer, you can use it anywhere you can find a monitor.
    • multitouch screen coffee table
    • Wall hanging screen with voice control for network pictures, weather, news and RSS feeds
    • Cyber Cafe computer
    • Video conferencing system
    • Personal weather station / logger
    • Control a light display
    • Control an LED board
    • Put it in an old mac classic or mac plus case as a general purpose computer
    • Intelligent photo frame with touch
    • Wardriving setup
    • A dedicated Synth, possibly with touch screen
    • Solar powered desktop computer
    • CNC controller
    • High tech birthday / Xmas presents
    • Backup server
    • RSS ticker
    • High tech alarm clock
    • Mini projector
    • DOSBox for games
    • Processing farm for SETI@Home
    • Cafe media player
    • Brains for Arduino setup
    • Mumble server
    • Industrial manufacturing controller
    • TOR server
    • BitTorrent seedbox
    • Family notice board
    • CD / DVD ripping device
    • Car black box with video
    • Wall mounted, interactive mood lamp
    • Robotic telescope / camera controller
    • Display photographer portfolio images
    • BitTorrent client
    • SMS gateway
    • BrewPi – beer brewing control
    • Kitchen TV/computer
    • Internet connected photo frame
    • Home monitoring
    • Digital signage
    • Personal/home/work dashboard

    So many good ideas it’s hard to choose.

  • Good Christmas Break

    It was a nice relaxing week off for christmas this year. Having friends around to host parties made everything more festive.

    The week was bitterly cold with a streak of -30 degree temperatures for the week. It made the deepfried Christmas turkey a bit harder to cook. Thankfully the cold snap is over for now and we’re back into temperatures closer to 0 for the next week.

    Went to see some friends in Edmonton yesterday and saw what was probably the most tech laden house I’ve been in. They had file servers with 96TB of disks, at least 6 TVs in the house each with a media computer on it. The workout area had a 100″ projection screen. Interesting setup that gave me some ideas for how to get things working in my house.