Category: PHP

Technical New Year’s Resolutions 2010

I try to do this every year by New Year’s Eve, but I’m a little late this year! Reflecting on my 2009 PHP/technical New Year’s resolutions, I ended up doing pretty well despite some unexpected challenges.

Zend_Log_Writer_Mail made it into the standard library, so that takes care of my Zend Framework line item to some extent. I didn’t propose anything new, though, but at least it’s something!

My goal to write for php|architect was realized in October with the publication of “Make It Mobile with PHP and Open Source Tools.”

I spoke at iPhone/Mobile Camp Atlanta 2009 with a modified version of “Rickroll To Go With WURFL, PHP, and Other Open Source Tools”, which was a great, low-stress speaking engagement. Hopefully it will take place again in 2010, because I’d love to participate again!

It’s been a busy but productive year for work-related technical projects as I helped lead a team to re-launch a medium-scale B2B marketing site for a large cable television network. That went over with a great degree of success. In 2009, my project roles tended to lean more towards non-development leadership roles, such as Solutions Architect. Late in the year, I’ve been acting as the technical lead and a developer, which has been nice. It looks like I may get to do more architecture and development work in 2010, so that will be a nice shift in gears.

In June, our daughter, Madeline, was born, which was definitely the highlight of the year. Then in September, we were affected by the 2009 Georgia floods when our house in Austell, GA was flooded. Then came the reconstruction and all of the headaches that came with that. So, the last half of 2009 was a wash…no pun intended. :)

But, the horrible year of 2009 is now over! Looking forward to 2010, I’ve got a few things I want to tackle:

  • Get back on the conference circuit: I avoided travel in the first half of 2009 due to Madeline’s arrival. I had planned to pick things back up in the last half of the year, but the flood kind of complicated those plans. Hence, I wasn’t seen at ZendCon or php|works. I want to get back on the conference and speaking circuits in 2010 — I need to write some new abstracts and manage to speak a few times. I’ll be starting in May at Atlanta PHP, tentatively talking on profiling and optimizing PHP applications with JMeter and Xdebug.
  • Write another article: I’d like to maybe write another article, either for php|architect or some other development- or systems administration-centric magazine. Writing an article is relatively simple, and gratification comes much sooner than with, say, a large book. I enjoy using my learnings from the real world to help impart knowledge on the masses, even if it only helps a single person.
  • Branch out; learn a new language(s): I consider myself an advanced-to-expert PHP developer. I’ve focused on LAMP/OPAL development for eight years now. I’d love to dabble in other languages such as Java, Ruby, Python, and so on. I’m also very rusty with C and C++, and my Objective-C/Cocoa skills could use some more refinement. I need to set a goal to build a specific, simple application, and build it in as many languages as possible. The challenge with this is time — I only have so much of it with work- and family-related commitments, but that’s what late weekend nights are for, right? Right?
  • Release an iPhone app in the App Store: I’ve got at least a half a dozen iPhone apps at various stages of completion in my personal SVN repository. They’re in need of more thorough ideas, or design, or a little bit of both. Once I hit a brickwall, I tend to lose momentum. This year, I need to barrel through those brickwalls and get something released to the public. I don’t want to get rich; I just want to be able to take an app from start to finish. I dropped the ball on this in 2009, so it’s time to commit to it and get serious. I may start off slow with a desktop app idea that needs to see the light of day.

So, here I am once again: starting a new year with a new set of resolutions. I can safely say that 2009 has been the most difficult year of my life, but I’m glad to see that it’s over, even though it’s been bittersweet.

With all of this behind me, I’m re-energized and looking forward to the new challenges that 2010 has in store. As long as they don’t involve any natural disasters, I think I can get through this year.

Happy New Year to everyone! Thank you again for the support you have shown during the ups and downs of 2009, too. See you all in 2010.

“Publish or perish”

‘Publish or perish’ refers to the pressure to publish work constantly to further or sustain a career in academia.”

Many years ago, my old boss at Community Connect Inc. (now Interactive One), Michael Montero, was having an article published in the September 2002 issue of Sysadmin Magazine. Around that time before the article was published, Mike enlightened all of us software developers on the “publish or perish” idea — write articles, speak at conferences, etc. in order to enhance your development career.

I always took that advice to heart. It made sense to me. If you’re good at something, you use your communication skills to better yourself and make yourself known. Whether it’s writing an article, writing a book, or speaking at a conference, it’s important to share your experiences and impart your knowledge to others.

So, that was one of my big goals for the year. I’ve done the conference thing for a while now, so I wanted to make 2009 the year of writing. By writing, I mean writing code, and writing an article. So, by the time this is posted, my php|architect article, “Make It Mobile with PHP and Open Source Tools” will have been published.

I started it early in the year and finished it in mid-April, many months ahead of the deadline. It’s basically my “Rickroll To Go…” conference talk, but in a written form.

It’s not some huge triumph of an article…it’s not going to win any awards…but it’s representative of a goal I set out to accomplish and succeeded at.

So, if you’re reading the issue, enjoy! If you’re not, go subscribe to php|architect!

Also, special thanks to my php|architect crew for giving me this great opportunity.

I’d like to do some more writing in 2010 (maybe some non-PHP writing, too?), so maybe you’ll see me in print again next year. Thanks for reading! Please send along any comments, questions or feedback via email or Twitter.

“Rickroll To Go…” ZendCon Session audio posted!

My ZendCon 2008 talk, “Rickroll To Go With WURFL, PHP, and Other Open Source Tools”, was just released at Zend DevZone as ZendCon Sessions episode #23!

If you’re just now finding my blog from there, welcome! And thanks to Eli White, Community Relations Manager for Zend, for selecting it for posting.

You can get all of the relevant info using the links below:

Slides and videos of the presentation materials
ZendCon Sessions page with audio
MP3 audio of the presentation
iTunes DevZone podcast

Enjoy, and thanks for listening! Find me on Twitter or email me if you’d like to discuss the materials.

MySQL replication and the sync_binlog option

Recently I’ve been focusing on MySQL replication for a project at work. On this particular project, I’m acting in a Solutions Architect role and have been since about September of 2008.

Because of my background in systems administration, I tend to get myself into situations where I become the Schematic-side sys admin on projects. This involves things like deployment processes, getting development, staging, and production environments setup, and now, setting up MySQL replication. This is probably because a) I’m probably bad at delegating these things to others, b) I’m kinda’ good at it, and c) let’s be honest, I’m a control freak, so I like knowing the servers hosting my apps are setup in a meticulous manner.

In short, we’re running MySQL 5.0.45 on RedHat Enterprise Linux 5 (I know, I know…RedHat and MySQL 5.0…boo…but it’s okay). We’re required to replicate our production database to a secondary machine for backup purposes. This way, if our production server dies, we can manually failover to the slave (once we enable writes to it, of course), then swap the two back once the production server is back up.

All in all, this site is rather low-traffic at around 20,000 dynamic page views per day. Factoring in US-based users in an 11 hour time period, that’s about 1,800 request per hour, or right around 0.5 page views per second. We’ve got a single server in production that’s acting as our webserver and database server; it’s got a RAID array in it that was all setup by the group hosting the application (so I don’t know tons about it, but it’s new, quality hardware).

I’m using my master database for reads and writes in Production. Again, the slave is really only required for live backup-type purposes.

Now, I’m no expert on MySQL replication, but I’ve learned a lot these past few weeks. So I’m going to share one big caveat here. Please correct me as you see fit!

MySQL’s got a sync_binlog configuration option. You typically set it in my.cnf, and its value is an integer from 0-n. This value determines how many binary log writes need to occur before its contents are flushed out of the buffer and onto disk. With it set to zero, your operating system just determines when the buffer is flushed to disk.

I have a database migration process that copies table structures and their data from PostgreSQL into MySQL, then basically migrates that data into the appropriate tables in the new MySQL instance. It involves the transformation of a lot of data. It’s a sizable, complete data set for 8+ year old system that’s not the prettiest, best normalized data model in the world.

Per recommendations in High Performance MySQL, I had my sync_binlog value set to 1 in Production.

When I was performing a test migration to Production recently, the process took about 3 hours. Wow. Thanks, MySQL! It normally takes about 90 minutes in Staging, if that.

In digging around Google and MySQL.com, I found that a non-zero value for sync_binlog causes more disk seeks to flush the binary log to disk. The benefit of having it set to 1 is so that every transaction can be written to the binary log, which is then flushed to disk upon commit. Then, if your server happens to die, the last completed transaction will always be present in the binary log on disk, so you never have to worry about, say, missing a transaction replay on your slaves. However, this results in a lot more disk activity on your master.

I set sync_binlog to 0 and re-ran my migration. It ran in 90 minutes — that’s a 50% performance gain! Now, if you do the math, this makes sense. It’s one less disk seek and write per-transaction, so this result totally makes sense. Hooray for numbers, right?

I’m willing to gamble the integrity of data on my slave for the 50% performance increase. (remind me of this post in 6 months when I’m kicking myself over this for some reason, okay?)

With no binary logging enabled (i.e. in our dev environment), this process takes about 20 minutes. This makes sense — far less disk writes during the process.

Another way to workaround this would be to keep your binary logs on a physically separate disk. However, I don’t have that luxury at this point, so that’s not an option for me. If I had my druthers, this is how I’d handle the problem, but…no dice for now.

Anyways, my main point: if you are willing to gamble with every single transaction being replicated to your slave in the event of a crash, perhaps you can set sync_binlog to 0. If you’ve got a separate disk to devote to your binary log, by all means, set it to 1! There are other concerns around this are related to battery-backed disk cache, which you can read a bit more about in Jeremy Cole’s post on MySQL replication. You can also see some handy benchmarks that compare MySQL with and without binary logging.

Finally, I’ll admit this is a bit of a knee-jerk reaction post. I’ve done a bunch of research on this, but it’s not all quite fleshed out in my mind yet. I get the whole cause and effect in theory, but I haven’t dug into MySQL source or other materials to really understand what’s going on behind the scenes.

MySQL replication is a tricky thing. It’s great when it works, but understand that there are overhead tradeoffs in using it! I’m sure I’ll learn more in the weeks and months following our launch, so I look forward to sharing more of my successes and/or pains on this. Comments, feedback, and flames such as “OMG, you’re so wrong Brian!” and “Brian is a n00b!” are welcome.

“Rickroll…” goes to print with php|architect!

One of my accomplishments during 2008 was preparing and presenting a new talk, “Rickroll To Go With WURFL, PHP, and Other Open Source Tools”. This talk focused on some of the challenges with delivering content to mobile device users, such as limited bandwidth, limited resources on the device, and varying device support for video and audio formats. It illustrated how to use tools such as the imagick extension and FFmpeg to deliver content and an experience that was optimized for mobile devices.

Or, another way to refer to it: if you were ever at a PHP conference and heard of some dude Rickrolling a group during his talk, that was me.

I gave this talk at Atlanta PHP, ZendCon 2008 and PHP Appalachia, and received positive reception and feedback in all cases.

Now, in trying to knock out my New Year’s resolutions, I am adapting this talk into an article for php|architect, which will be published around October 2009.

I’ve only got 3,000 words to work with, so I may not be able to address all three major content areas — images, video, and audio — but I’ll do what I can. The focus of the issue will be “graphic manipulation,” so focusing on the image portion may end up making the most sense given the word limitations. You don’t want to read more than 3,000 words worth of my ramblings anyway.

So, keep your eyes open for that issue later in the year! Also, special thanks to Elizabeth Naramore, Beth Tucker Long, and Marco Tabini for the opportunity to grace the pages of their fantastic publication with my words, ideas, and experience.

Also, another special thanks to my co-workers JP Crevoiserat and Joseph Jorgensen who worked with me on a project that inspired the talk and this article. And as always, a special thanks for Schematic for always supporting the community-related efforts of its employees.

WordPress Themes