Reputation: 123
Subjective question, I know, but I am counting outgoing clicks for a very specific part of a website, and I'm simply needing to keep a tally of outgoing clicks per link and per day. I know that I could use MySQL for this, but I am wondering if there is something smaller/more-efficient for this application.
I manage my own server on slicehost running Ubuntu 9.10 with Apache/2.2.12 and could install something, however, is there something that is small and easily dropped in for small applications like this?
Perhaps something that writes to it's own file within the site.
Clarification: this question is about the efficiency of code required to simply setup small things like this. I do not have nor anticipate performance issues. I'm curious what other people use for things like this. Maybe it is MySQL - I'm here to learn.
Upvotes: 0
Views: 866
Reputation: 562661
You could use Memcached as an in-memory cache for your hit counter.
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$m->add('counter', 0); // no-op if key already exists
$m->increment('counter');
Then you would run another script offline every minute or so to read the hit counter, add it to a persistent database, and reset the counter to zero.
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$count = (int) $m->get('counter');
$m->set('counter', 0);
$pdo->exec("UPDATE mytable SET counter = counter + {$count}");
Upvotes: 1
Reputation: 4441
Since you've parameterized your architecture by using code efficiency as a metric instead of performance under load (or whatever), just go with whatever database technology you're most familiar with. This will drastically reduce code writing and debugging time.
Of course, you might also want to take this opportunity to learn a new database technology. If that's the case, then find out what would make you more valuable to your current or future employer(s) (ie., they might be looking at a different technology for a new product, which you can become the in house guru of), what new databases are "up and coming", etc.
Upvotes: 0
Reputation: 4682
You can do smaller. You can do more efficient. You're not really going to get both in the same package.
Really, I'm with Peter Bailey on this. This whole question reeks of pre-optimization. Do you actually have a performance problem that justifies using an additional database?
Upvotes: 2
Reputation: 105906
You could use SQLite but honestly, this entire question reeks of pre-optimization.
Upvotes: 2