Personal.X-Istence.com

Bert JW Regeer (畢傑龍)

2010 -- Where is HAL to tell me that it can't do this?

The absence, or rather outdated blog posts on this blog have a myriad of different reasons for existing, and while I feel guilty for not having updated nearly as often as I believe I should have it was with good reason.

2009 was my year. It was the year that I completed an awesome internship courtesy AEC Consultants, and it was also the year that I completed my last two semesters (I took a break over the summer, my first break in eight semesters of non-stop schooling). This past December 22nd, 2009 I turned in my last assignments and my paperwork for my degree application. If everything goes right (and that is a big if, considering UAT has screwed people over before), I will have finally graduate with a Bachelor in Computer Science: Software Engineering, or something along those lines. It took me nine semesters, over a three year period to complete my degree.

Only recently has it begun to sink in that finally I am considered to have the knowledge and the know-how to be responsible enough to WORK somewhere. Society believes that people that own a simple little piece of paper that says I have a degree means I can be a meaningful part of society. Little did they know they were wrong, but let them dream! ;-).

Yes, this also means that this time I am looking for a full-time work position. In the past year I have found that Phoenix is not exactly the greatest city for finding work in the software engineering field, however I will keep looking.

There is one thing going for me, a major company located in California contacted me, and asked me if I would like to work for them. I eagerly answered yes, and I am now going through their very rigorous and stringent interview process. To me it is an interesting challenge and so far I am actually enjoying it.

A new chapter has started in my life, and it was started in full with the change from 2009 to 2010. Kind of fitting that my life takes a major new turn, with new roads and new obstacles after society as a whole celebrates having lived yet another 365 days through four different seasons (there where seasons exist, Phoenix does not count).

Grilled Cheese Sandwich, Re-invented

While I may not be a master chef coming up with great new ideas to make people's mouths water, I do enjoy experimenting with new ideas. Two of my favourite easy to make food items are "Eggy in a Basket" and ever since Katie showed me the "real" way to make one, the grilled cheese sandwich. Grilled cheese sandwiches are absolutely amazing, however there are improvements that could be made.

After Katie butters two pieces of bread, she throws on some parmesan cheese along with some garlic salt, then in a hot skillet one side goes, stack some shredded cheese on top, and place the second piece of buttered bread on top, butter side up. Wait for the bottom piece to brown, then flip the whole thing, grill until the bottom is brown and crunchy. Absolutely tasty, I am making some modifications in an attempt to make it even better by adding an egg to the mix.

What you need (Makes 1 sandwich):

1 Egg 2 Slices of Bread (Sourdough works really well, anything sliced thick) 1 cup of shredded cheese (Or more, this is too taste) Parmesan Cheese Garlic Salt and/or Italian Seasonings (as desired)

Here are the steps, along with pictures:

  1. Butter the bread on one side, and cut a hole in the middle of one of the slices.

Add on some Italian Seasonings or Garlic Salt to taste, and cover in parmesan cheese.

  1. Place the slice of bread with a hole in it, butter side down in the pan, and crack the egg into the center

Cover with a lid to help the egg harden.

  1. Once the egg whites seem to have mostly solidified, flip it over. Now stack cheese on top.

  1. Place the other slice of bread on top, and cover with lid again.

  1. Once the butter on the top slice of bread starts melting and the bottom slice of bread has sufficiently hardened crusts, flip the whole thing over.

  1. When the bottom slice of bread has sufficiently browned and has become nice and crunchy it is time to consume it

  1. Cut it down the middle, depending on how long you cooked it the yolk should still be a little runny or soft:

(please be aware that eating raw or undercooked foods can pose a hazard to ones health, I am not responsible for any illness because of your inability to cook foods properly)

  1. Enjoy the Eggy in a Grilled Cheese Sandwich.

From the creators of SPIN comes Ink

Two or more years ago in a post named "SPIN -- Awesome" posted a YouTube video which was absolutely fantastic, it was a short named SPIN. I have started reading Reddit lately, and came across a post by the creators of said short: Kiowa Winans which have created another awesome movie that is getting a lot of rants and raves: Ink.

In the Reddit post they tell people how many times it has been downloaded and also ask for donations to help their studio thrive, as well as getting the word out to many more people. The movie is now available on NetFlix as well at NetFlix Ink page. It is available for a watch now, AND a small kickback will be given to the DoubleEdgeFilms studio to keep making great movies.

I have yet to watch the movie Ink myself, I will post an update later today or tomorrow when I get a chance to sit down and watch it!

Moving from `mod_fastcgi` to `mod_fcgid`

Update: I've since moved to a PHP-FPM with mod_fastcgi based setup which works much better than mod_fcgid could ever dream of, taking process management away from Apache and putting it where it actually makes sense has improved server load and improved website speed. See my new PHP-FPM with mod_fastcgi post for more information.

--

Errors, all they cause is trouble. The dreaded 500 error showed up when visiting my favourite tech website, the one I am the administrator for. This time I had enough, there was going to be no more playing around with PHP settings, attempting to figure out why PHP was suddenly dying and or why mod_fastcgi refused to retry a select() when it failed due to a system signal.

The server in question runs Apache in MPM worker mode since a threaded Apache is going to be faster than a pre-fork, besides this server does not have as much memory so it seemed to be better to have multiple threads rather than multiple processes, each of which would have their own memory segment. There however is the issue that this server also needs to run PHP, the accepted method to do so is to use mod_php along with Apache; however PHP is not thread safe.

The alternative is FastCGI, basically it spawns PHP processes as a separate stand-alone process, with their own memory space, much like Apache pre-fork, however now when one process grows to big, or when a process is no longer needed it can be cleaned up, keeping memory to a minimum. Also, FastCGI is perfectly thread safe, this means that with Apache running in MPM worker mode we could now still run our PHP scripts even when they were not thread safe.

Setting up mod_fastcgi is not that hard, it takes some httpd.conf configuration values, and off course the loadmodule is assumed here:

# Set up mod_fastcgi
<IfModule `mod_fastcgi`.c>
    FastCgiIpcDir /var/tmp/fcgi-ipc/
    FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240 -pass-header HTTP_AUTHORIZATION

    AddHandler  fastcgi-script              .fcgi .fcg .fpl

    Action      application/x-httpd-php5    /fastcgi-bin/php5.fcgi
    AddType     application/x-httpd-php5    .php .php5
</IfModule>

# Set up the script alias, basically anything in this directory gets executed as a fastcgi script
ScriptAlias /fastcgi-bin/ "/usr/local/www/fastcgi-bin/"
<Location /fastcgi-bin/>
    Options ExecCGI 
    SetHandler fastcgi-script
    Order allow,deny
    Allow from all
</Location>

Because of errors that mod_fastcgi was throwing out at me, I figured mod_fcgid is worth a try. However all of the configurations I found required me to add an FCGIWrapper line into each of my VirtualHost blocks, which was an immediate no-no since there is well over 100 of those on the server, and I'd rather spend my time doing other things.

With some trial and error, and some Googling I put the following together for mod_fcgid, tested it out, and once it worked perfectly set Apache off running with the following configuration:

# Set up mod_fcgid
<IfModule `mod_fcgid`.c>
    AddHandler  fcgid-script                 .fcgi .fcg .fpl
    IPCCommTimeout 60
    SocketPath  /var/tmp/fcgi-ipc/

    Action      application/x-httpd-php5    /fastcgi-bin/php5.fcgi
    AddType     application/x-httpd-php5    .php .php5
</IfModule>

# Set up the script alias, basically anything in this directory gets executed as a fastcgi script
ScriptAlias /fastcgi-bin/ "/usr/local/www/fastcgi-bin/"
<Location /fastcgi-bin/>
    Options ExecCGI 
    SetHandler fcgid-script
    Order allow,deny
    Allow from all
</Location>

Notice how similar they both are, that was the whole goal. mod_fcgid was supposed to be a drop in replacement, and thankfully it was. PHP was served as it once was, with a twist.

The php5.fcgi script is as follows for those of you trying to set this up as well:

1
2
3
4
5
6
7
#!/bin/sh
# To use your own php.ini, comment the next line and uncomment the following one
#PHPRC="/usr/local/etc"
#export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
exec /usr/local/bin/php-cgi

Some things that that intrigued me is that my php processes seemed to be capped now. Where mod_fastcgi would spawn processes but never remove them or kill them when they were no longer needed, mod_fcgid keeps the running php processes to a sane limit instantly starting new processes when required to handle the requests coming in. This means that the server now has more free memory for MySQL, or file caches which has helped speed up other types of transfers as well. Even with the relatively short time that mod_fcgid has been in place it has been faster, more reliable and more sane than mod_fastcgi. Whichever one you pick, make sure to benchmark your server and check your error logs to solve common issues, the issue may not be what FastCGI module you picked but rather PHP itself that is causing the errors!