This week I had the privilege of doing load testing on an aws setup. The goal of the test was to support 25k concurrent users and was designed to ramp up over a period of a few minutes. The first round of testing failed pretty quick and I only had a select number of large queries cached. So the db spiked and was the bottle neck. During that test we was only able to reach 10k concurrents.
For the second round of testing I decided to just setup output caching before I even loaded the db in a MY_Controller. I set the number of minutes to something relatively high and was ready to commence the load test. Unfortunately this test maxed out the db again and I was honestly scratching my head on just why that would be the case.
Since this didn’t make any sense to me I decided I better figure just what is going on. I got my local system setup the exact same way, enabled mysql query log, and then proceded to test and see what was going on. Queries was being ran even after the cache file was written. At this point it was way late so I decided I better sleep on it and try and think about what I was missing.
The next morning I got to work ran the same tests and got the same results. Starting researching and then realized it was just my ajax calls that was generating the queries. This had me puzzled because the ajax controller extended the MY_Controller so it should be cached as well. Turns out I was wrong and missed the most important note in the user guide:
Warning: Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a view.
The more I thought about it the more sense that makes since the Loader ties into the output library but I wasn’t thinking clearly at 3am. Looked at my ajax controller and sure enough I was just returning a json string.
The quick fix was to change the return to the following:
My hope is this will help others if they ever run into the same situation. Unfortunately the load testing was only scheduled for two rounds but I feel confident by fixing that it would have passed with flying colors.
So the moral of the story. READ THE MANUAL :-)
Not only will I be a part of a great company but they have also hired the creator of the Laravel framework, Taylor Otwell. I have been watching that framework closely the past few months and I am very impressed with what he has done with it. Laravel’s motto is:
Laravel is a clean and classy framework for PHP web development. Freeing you from spaghetti code, Laravel helps you create wonderful applications using simple, expressive syntax. Development should be a creative experience that you enjoy, not something that is painful. Enjoy the fresh air.
The simplicity of framework is what drew me in originally. But now it will just keep getting better and better because it will be the framework of choice for Userscape. The reason I feel this way is that HelpSpot can be purchased as either a downloaded application or hosted with their partner Engine Hosting, so Laravel will be tested in a wide range of different hosting environments.
Even though my day job will be with Laravel I still love CodeIgniter and I am still on the CodeIgniter Reactor team. CodeIgniter is and has always been near and dear to me and I really enjoy using it. Plus I will be doing contract and freelance work for companies that are heavily invested into it. I am very excited with where CodeIgniter v3 is heading and I think it is a big step in the right direction that we have all been wanting.
I always like reading lists of apps that developers use on a daily basis and I love finding ones that I have never heard of or never gave a chance. As 2011 comes to a close I wanted to share my favorite apps that I use on an almost daily basis.
Not a mac app but still the framework I use every single day and write posts about all the time. :)
This is a must for every computer that I own. I love the quick application launching, calculator, and custom commands you can use.
Previously I was using just the standard mail app but when 10.7 came out I really disliked it. So I found Sparrow and have been happy ever since. It is nice and light and does just enough for what I do.
I don’t always use a git gui, but when I do I choose Tower. I like the quick visual diffs and the clean layout. Another great git gui is gitbox which I use as well.
I use Mamp Pro just because it is easy. I like the fact that I can setup vhosts through a gui and not have to worry about installing apache, php, and mysql. Another benefit is that I work with a bunch of designers and with us all using Mamp I know what I build will run on their systems with out me having to do anything.
This is my code editor of choice right now. It is awesome and you should try it if you haven’t. More Sublime Text Posts
I found this a few months ago and it is really great for browser testing and inspired by Automator. So it is really simple to setup and use.
I use this every day to create notes, ideas, and write out features before starting coding. I have this setup to sync with dropbox so my notes are always available. More Tips
I have to connect to several dbs throughout my day and this app makes managing mysql a breeze.
CoRD is a Mac OS X remote desktop client for Microsoft Windows computers using the RDP protocol. At work we have a lot of old legacy sites that are running on windows hosting and I really like this app because of its speed compared to others I have tried.
For other common day to day applications I use Chrome as my browser, iChat, Textual IRC, dropbox, and Feedly for my rss feeds.
I finally switched all my domains off GoDaddy and moved them to hover. What is super awesome is they offer a “Valet Transfer Service”.
We want to make moving your domains a painless experience whether you have 1 or 1000 so we will handle these messy details for you at no charge.
I only have 10 domains but was really dreading going through the transfer steps and of course thinking about fighting with GoDaddy’s management console made me cringe.
If you are looking to switch registrars I do recommend them.
I am happy to announce a simple CodeIgniter library to help you generate slugs for your urls. This is something I use on almost every project and it has been invaluable to me. Hopefully you will find it useful as well.
For those that are not familiar with the term slug WordPress defines it as:
A slug is a few words that describe a post or a page. Slugs are usually a URL friendly version of the title.
What this library does is allow you to pass a string such as a titile and then generate a url friendly string from it. Also and most importantly it checks against fields in your db so that you will not have any duplicates. For example:
"This is my title"
If a duplicate is found then it appends a number. Example:
First load the library with an array of config items:
$config = array( 'table' => 'mytable, 'id' => 'id', 'field' => 'uri', 'title' => 'title', 'replacement' => 'dash' // Either dash or underscore ); $this->load->library('slug', $config);
When creating a uri for a new record in your db you can do it like this:
$data = array( 'title' => 'My Test', ); $data['uri'] = $this->slug->create_uri($data); $this->db->insert('mytable, $data);
Then for when you are editing an existing record: (Notice the create_uri uses the second param to compare against other fields).
$data = array( 'title' => 'My Test', ); $data['uri'] = $this->slug->create_uri($data, $id); $this->db->where('id', $id); $this->db->update('mytable', $data);
You can clone the repo by running the code below:
$ git clone git://github.com/ericbarnes/CodeIgniter-Slug-Library
Or visit the GitHub Repo.