Always Get Better

Posts Tagged ‘e-commerce’

Memcache as MySQL’s Hero

Sunday, April 10th, 2011

It’s hard not to love memcache. As soon as you manage a web site that has more than a few concurrent visitors, the performance benefit of caching becomes immediately obvious. MySQL is a fast database and can outperform a lot of its competitors, but no matter how quickly it can pull results it can never outperform the retrieval speed of the server’s RAM.

The basic premise is: instead of pulling a model out of the database, see if it has already been loaded into memory by checking a key-value diction (for example: User5677). If the user has not been read from the database yet, the key-value store will be empty and we can fetch the record. Next time we need that data we check the key-value again and avoid querying the database.

This really saves us whenever we have data that changes infrequently. Take, for example, an ecommerce website: since the products and categories on the site will change very rarely, it makes a lot of sense to store them in memory for fast recovery. Even more volatile information (like user data) can be stored in the cache, as long as the application knows to empty that cache key when the data gets changed.

Memcache is an ideal tool for managing these kinds of caches, and provides a lot of flexibility for growth.

History Lesson
Earlier this week I promised to go deeper into memcache’s origins. Memcache was originally developed at Danga as a way to reduce the database load and improve the speed of LiveJournal.

Rather than developing a standalone server application, Danga’s engineers designed memcache to sit on lower-end hardware and on web servers where it would use a small amount of the overal memory. Memcache instances don’t talk to each other: the client machines are aware of all the memcache instances and attempt to write their information evenly to each. This allows memcache to scale almost limitlessly without adding significant overhead to the caching process.

When to Use
Quite simply: if you’re building an application for the LAMP stack, build in memcache support. When treated as a necessary component from the beginning, caching support adds almost zero overhead to development; however it will always pay off as soon as real world traffic is coming to your site.

Command and Control Social Media

Friday, April 8th, 2011

From a branding perspective, social media is about joining the conversation rather than trying to constantly send out broadcasts. Any idea worth discussing is already being talked about – if you ignore social media you aren’t just failing to get your message out into the wild; you are, in fact, allowing your voice to be absent from the existing discussion. There is a seismic shift occurring in the way brands and their respective owners are thinking about engaging their target audience. It isn’t good enough to just get the message out anymore – more attention is being placed into measuring the effectiveness of that message.

This isn’t a new idea; in fact, people have been talking about brands for as long as brands have existed. It’s well known that behind every customer who speaks up about their disappointment or service problem are ten others who simply switched to a different supplier. Figuring out what people are saying “on the street” and reacting to improve based on customer expectations isn’t a new concept; Facebook, Twitter and the blogosphere are only tools that make this much easier – they did not invent the conversation. So what’s the big deal?

The difference we are seeing today is the easy access to information that was not present before. Employees at all levels of the organization have access to the same outside data, the same instant feedback to everything being done. Ofttimes the worker at the lowest level has more sense of customer feelings than does the decision-making upper management – this has always been true, of course, so why the sudden magnification?

I believe we are seeing a generational change in business and mindset that is putting people ahead of function. Call it Generation X (over-workers to a fault) passing the torch over to Generation Y (family-focused individuals). In the next several years we are going to see a greater focus toward grassroots-based marketing efforts and a continuation of the trend toward niche-based services alongside the dismantling of mainstream distribution channels.

How to control this? Don’t. Service the customer and listen to their feedback. The same ingredients that have always made businesses successful are still in place: the difference is it is now easier than ever to hear the feedback faster.

Wamp Server Crashes Installing X-Cart

Sunday, January 24th, 2010

When running a default installation, WAMP Server’s Apache crashes when installing X-Cart. The error happens immediately after setting up the MySQL tables and is caused by the curl extension in PHP.

To resolve, click on the WAMP Server icon in the task tray, go to Apache -> Version -> Get More. Download one of the 2.0 series Apache servers and install it.

Repeat the process for PHP; download one of the 5.0 series PHP versions and install it.

Switch WAMP Server to the new versions and run the install again – it should work with no problems.

GoDaddy Hit by DoS Attack

Thursday, January 15th, 2009

Until recently, Always Get Better was hosted by GoDaddy. We moved in November so I could have better control of the various web sites I am running. I can say that I was not unhappy with the service offered by GoDaddy – I just outgrew it.

I guess I got lucky this time. According to cnet, GoDaddy was struck by a denial-of-service attack on the morning of January 14, 2008. There are conflicting reports (naturally) of the exact number of sites affected ranging from several to several thousand.

RIAA Changes Tactics

Monday, January 12th, 2009

The RIAA has had an interesting few years. Their business model is dying and they have been fighting to save it by suing evil music thieves like single mothers on disability pay, deceased grandmothers and, most heinous of all, families who do not own computers.

Now the Association has backed off slightly and switched to a more cost-effective method; at least, they have offloaded the burden of identifying music pirates to the ISPs that host them. Rather than issue subpoenas to service providers for the names of their downloading subscribers, the RIAA has switched to sending lists of IP addresses and evidence to those ISPs it has partnered with. The ISP can then take measures into its own hands by:

  • sending warning emails
  • sending warning letters
  • reducing bandwidth/speed of violators’ Internet connection

It works for everyone except Internet users – the RIAA gets counter-sued less because it is no longer serving papers to innocent bystanders victimized by faulty IP records or the delays between court orders and identifying information (leading, for example, to charges against families who don’t even own a computer when in fact the former occupants of their home was involved in downloading). The ISPs get an excuse to rid themselves of customers who make full use of the bandwidth and network resources they are paying for.

I recently heard an argument that people who download or otherwise pirate a particular piece of software or music are unlikely to have purchased it at all therefore prosecuting them is pointless since they would never have been a customer anyway – the creator of the downloaded content hasn’t “lost” money. Where I come from, if we aren’t willing to pay for something for any reason idealogical or otherwise, we simply do not own it – we don’t try to source it for free. I’m not defending the RIAA, I just don’t understand the value derived from downloading libraries of music.

Apple is Having Babies

Monday, December 1st, 2008

We rented Baby Mama this weekend. I was happily surprised to find PC Guy in the role of the fertility doctor – perhaps a nod to Mac Guy‘s film appearances. It warms my heart to see those references transitioning into the cultural lexicon. All this got me thinking about Apple’s “Get a Mac” campaign; there have been some funny ads circulating around the net lately, including some Flash videos seemingly spreading between ad spots (how do they do that?).

The newest byte is that due to a shortage of trained developers, talented programmers can earn $125-$200 per hour by developing iPhone applications.  Unbelievable!  Where is my old iBook when I need it – buried under a stack of music CDs with an old version of OS X that doesn’t support the iPhone SDK.  Maybe the time is right to spring for a new laptop if there is a potential to earn $250,000 by creating a decent marketable application.  Gold rushes like this don’t act long – talk about striking when the iron is hot!

How to Create Full Text Search Using mySQL

Thursday, February 14th, 2008

Search is one of the most basic features visitors expect when they come to a web site. This is especially true in e-commerce where your ability to make a sale is directly related to your customer’s ability to find the product they’re looking for.

Using Third-Party Solutions

Many first-time site owner choose to go with Google Custom Search because of its easy setup and because of Google’s incredible indexing reach and results. I don’t like the standard edition of the Custom Search because of the branding – your search results advertise Google and provide links to competing content. For an e-commerce site to lose control of such a critical function, the results can be costly.

Don’t Give Up Control

Especially in e-commerce, it is best to never give up control over any content. Advanced users may choose to ignore your site’s search tool and use Google to get at your content anyway (via the site: directive) but in the general case there is great potential to keep selling useful products to your potential customers even while they search your site for other items.

Incorporating a decent search tool into a web site using PHP is dead simple. All it involves is a database table with 3 or more rows and a little bit of an eye for layout. Even if you don’t consider yourself a designer, having a look around other search engines will give you a feel for how results should display.

Creating the Search Tables

Let’s get started. Our simplistic database table (PRODUCTS) will consist of the following columns:

Column Name Data Type Description
intID int Product ID and Primary Key
vcrName varchar(25) Product Name
txtDescription text Product Description
vcrPhoto varchar(40) Path (URL) to product photo

Obviously this is just a simplified example, but the product ID, name, description and photo should be enough for the purposes of our demonstration.

The SQL to create the table looks like this:
intID int auto_increment,
vcrName varchar(25),
txtDescription text,
vcrPhoto varchar(40),

Add the Full-Text Index

In this example, we’re interested in searching the name and description fields of our products. In order to add the full-text index to our table, we use the ALTER TABLE command:


Alternatively, we could have created the index along with the table in our original CREATE statement like this:

intID int auto_increment,
vcrName varchar(25),
txtDescription text,
vcrPhoto varchar(40),
FULLTEXT( vcrName, txtDescription )

Searching For Text

Now that the index has been created, we can go ahead and search the database. To activate full-text search, we use the MATCH () AGAINST () syntax like this:

SELECT intID, vcrName, txtDescription, vcrPhoto
WHERE MATCH( vcrName, txtDescription ) AGAINST ( ‘search terms here’ );

That’s all there is to it! Anyone with access to a mySQL database should be able to incorporate search into their sites without too much difficulty. Of course this is a very basic introduction, but should be more the sufficient to get going with.