Posts Tagged ‘MeraTech’

The Trick with Database Optimizations

posted by Mera
Thursday April 5, 2007

There's always a catch, right? Of course there is. One thing to take into account with database optimizations is that you don't optimize the database over the system it's running on. In other words, don't let it take up so much memory that the system is swapping memory to and from the hard drive swap space constantly.

I ran into this problem a few weeks ago with BanLink. The system was having all kinds of difficulties and then noticed that it'd gobbled up so much memory that it was spending half the time swapping the database cache from the disk cache.

Another catch, at least in my case, but I've read of a few others, is that MySQL will not *always* restart after you've changed the database settings. In other words, it shuts down fine, but just refuses to start. The solution I've found to this is to blank out the configuration, start it up, apply an updated configuration, and restart. It doesn't *always* work, and I don't even really understand why it should work, but it's about all I have to go on.

I experienced this a few weeks ago, only I couldn't get my new settings to take. No matter what I tried, the database refused to start with any optimized settings. So I just let it start up unoptimized. That worked. The stats on the site weren't even all that bad, so I let it run for a while.

That was short-lived, however. A good test of your optimizations are to run it without them for a while. Ok, that's a really poor test. Averaging around 10 seconds to respond was not a pretty thing. But I finally managed to get some of my new settings pushed into the database. We're back to sub-second responses, and we're not eating up all the memory of the system to do so.

The point? A good DBA pays attention to their database and doesn't let it win the battle…and it will fight you.

BanLink Update

posted by Mera
Friday March 2, 2007

Ok, time for another of my wonderful BanLink updates.  I haven't done this in a while, but I should.  Even if all of you hate it, it still is nice to keep track of what's going on.  It'll be fun to look back on at least.

The database, thank goodness, has been running pretty smoothly lately.  I did have to push in a few additional memory tweaks last Wednesday to make sure it's caching as best it can, but so far the load on the server has been minimal.  This is a very good sign considering we've more than tripled the amount of traffic that the site gets in the last month.

The latest work has been completely web related.  I'm excited and looking forward to the BanLink 2.0 web release.  And yes, it really is coming.  I've spent a lot of time rebuilding the core of the system and am now putting it within a pretty interface.  Using all the modern technologies available, like AJAX routines, the site is becoming much easier to navigate and hopefully will provide for a much nicer user experience overall.

When I built the original site, it was done in a fairly rushed fashion just to get the web and SL to interoperate.  The more interactions we needed, the more was added to the site.  This is what accounts for the lack of cohesiveness in a few of the screens.  It's also why the system seems so slow at times.  Communicating back into Second Life via RPC is slow, especially if the sim that the RPC box is housed in is running a little sluggish.  It'll get there, but it may take a few seconds.  Add to that the sites that have 20 boxes to communicate with, and you find yourself sitting and waiting and *hoping* things are working.  The new site will have a much more logical layout, meaning less need to hop between screens to do similar things.  It's also going to help with communications as they will now work in parallel.  And you'll get a status message to keep you up to date on what's happening.  Isn't that nice?  Yes, it is.

There's good stuff to come.  Thanks to everyone who has supported the BanLink system.  It's nice that we're hearing more and more success stories as of late.  It helps to keep us going when we know the system is providing use to folks out there.

A sneak peak, you say?

Continue reading

Continuing the Database Optimization Tips

posted by Mera
Wednesday February 14, 2007

It's been pointed out to me that I should remind everyone that these techniques can really only be applied when you have complete control over your MySQL instance. Many users in a hosted environment don't have this control. However, most users won't need to worry about this sort of tuning. It is important, however, when you have a heavily used system, such as BanLink, where you're getting constant transactions 24×7.

So this is part two in our MySQL Database Tuning series.  Last time we looked at the number of opened tables versus the number of tables cached. Next we're going to look at the index buffer. The trick is that you want to give as much memory as you can (go figure) to the index buffer without allocating all of the memory in your system.

The rule of thumb is to set it to a quarter to half of the available memory in your system, provided MySQL is the primary use of the system. How can you tell when you've got enough memory and things are working great, well we again return to the extended-status that we talked about last time. There are two status variables that we'll need to look at: key_read_requests and key_reads. You'll want to divide key_reads by key_read_requests. You wan that resulting number to be less than 0.01. If it's not, bump up the key_buffer value in your my.cnf file.

A companion to these values are key_writes and key_write_requests. As above, divide key_writes by key_write_requests. This time you want the result to be less than 0.1. Again, this is affected by the key_buffer setting in your my.cnf file. Once you have it tweaked to where both your reads and writes are optimal, your database will be nicely humming along.

BanLink & Databases

posted by Mera
Sunday February 4, 2007


Time for my weekly BanLink update, I suppose. After last week's changes, looks like I've got things on track finally. We're processing a little over 92,000 commands from the in-world objects per day and the average response time is less than 1 second and the server load average for the day is .24. In other words, things have finally come together. I'm all for sharing knowledge, so I should use this time to talk about what was actually done. I won't post everything all at once here, mostly because I could go on forever at a time, but consider this part one of a multi-part posting.

First off, this is a MySQL database. MySQL is fast, lightweight, and free. Plus it ties in to most languages pretty easily. I'd fiddled with tuning MySQL a little in the past, but in general it's never been really necessary outside of commercial applications. Well this site made it necessary, obviously. So what do you do? First step, get some stats out of MySQL by running this command:

mysqladmin extended-status

This will output a whole bunch of status information for your to peruse. Remember that this status information is also a snapshot of what's happening right when you ran it. So it's best to run this during peak performance times so you can get a "worst case" view of what's going on. Your MySQL database will have a configuration file, typically called my.cnf and living in /etc. You will want to make your changes within that file.

Now, what should you look at first? Well one choice is to look at open_tables. This status will tell you how many tables are currently open. There is a corresponding value called opened_tables. That one, obviously, will tell you how many tables have been opened. Now check in your my.cnf file for the setting, table_cache. If your table_cache setting matches your open_tables value, and the opened_tables value is much higher, it's a good idea to bump up your table_cache value. This will allow MySQL to cache more tables. Yay for caching. If, however, you see that your table_cache setting is higher than your open_tables value, then you know you can decrease the number of tables you need to cache. No point in allowing MySQL to cache too much and take away memory for no reason.

Thus ends part one. Hopefully I'll be able to explain things more clearly as I get more practice at this. In the meantime, happy optimizing.

BanLink Update

posted by Mera
Sunday January 28, 2007

It's time for a BanLink update. We've been working pretty hard on this system the past few weeks. Travis is gearing up for a new in-world release, and I've been continuing with the back-end optimizations. The plan is to get the database into working in a more streamlined fashion, and then work on updating the website. I know those of you that use the website do not think it's ideal, and it's not. The website was more or less thrown together at the start of this whole project and bits and pieces were put together as it grew. Now that we know more of how the site can and needs to be used, we can update it and make it more functional. We have already received a list of enhancement requests from you folks that have been using the system, much of those had been on our own list of enhancements since the beginning. Now, finally, they will come. Thanks for waiting. :)

Back to the latest bit of work, though.
Continue reading

I’m happy and sad for you

posted by Mera
Friday January 5, 2007

Well, happy and sad for me, actually.

The server tweaks that I've done have really made a difference, but I'm a bit confused by what I'm seeing, I have to admit.

You see, the improvements really did work on the server as a whole. The load average stays pretty low most of the time. The average in a 24 hour period is 1.2, but during light times it hangs out at 0.5. This I like. What's rather surprising, however, is that the execution time of the controller script is at around 1 second. I really expected it to drop to sub-second execution. In fact, with it running for so long, I really expected the server load to be higher. This is what's bothering me. How is it that the app is running without a lot of improvement, but the server load has improved dramatically? My suspicion before was that the DB was the bottleneck in the whole process and once that was improved, the app would return immediately. I guess it really is time to fix that program and see where the hangup is.

Speaking of evil. Tuning Databases is right up there. Sure, you get to run through and check table reads, index caching, memory allocation, etc. It's like a big puzzle that you get to analyze and put together. You definitely have to be in the right mood for it or it can just be a world of suck. But the bigger problem is when you make changes and then the database refuses to restart. Sure it exits just fine, but the important part is starting back up. Twice I've had the database refuse to start after making some tweaks. And it doesn't really complain about any of the changes. To make matters worse, untweaking doesn't help. So far what I've found is that I have to replace its configuration file with one that's empty, start the server, replace it with a tweaked config file, then restart. Things then seem to go just dandy. I don't make the rules, so don't blame me if that sounds silly.

It’s on!

posted by Mera
Tuesday August 22, 2006

BanLinkIt's finally official, after many weeks of development, BanLink is live! Oh sure, we have a whole bunch of enhancements planned, but it's up and it's stable, it's working great, and it's ready for release.

BanLink is a project developed by Travis Lambert and myself. Simply put, this is a free, open-source system to allow land owner groups to share their ban lists with like-minded groups. It's *not* a global ban list, though. What it does is allows groups to share data, opt-in to other group ban lists. And once you opt-in to another groups ban list, anyone the other group has banned will then be banned from you land. At the same time, you can still unban people from the other list to allow those that are banned from the other group to have access to your land only.

It's been brought to my attention that I'm a bit cryptic on this site at times with my postings. This is one of those cryptic things I've mentioned in the past. Travis and I have been working many a late night getting this thing up and running, but I've not been able to say a whole lot about it. We're pretty satisfied with how things work right now, I hope it receives a good response.

Class Proposal

posted by Mera
Sunday August 13, 2006

I'm all about the communication. No, not that kind of communication, but communication in and out of the SL world. XMLRPC and HTTP Requests. That's the fun stuff. I've done a lot of it, and I'm doing a lot with it. So I'm thinking of teaching a class on it. Let's see, what would we cover?

  • What's the difference between a remote data channel and an HTTP request?
  • How to open a data channel
  • Sending XML-RPC calls from an external source (PHP)
  • How to send HTTP requests
  • Responding to HTTP requests from an external source (PHP)

That could probably fill an hour. What do you think, sound interesting? Am I missing a topic (that won't run me two plus hours to get into)? Or perhaps, should there be multiple but more detailed classes?

Or maybe I should just give up and admit that I don't have time for it.

Help!

posted by Mera
Friday May 5, 2006

Ok, I know there's about 4 of you that read this, and I've already got 3 of you helping me, but now I need a few more. Guess I need to expand my readership.  :)

If you're interested in a programmable online status indicator for your website and feel like doing some beta testing, please let me know. I've got a few more ideas up my sleeve and I need a few people to test things out. Respond here (be sure to tell me your SL name) or contact me in-world and I'll set you up. Thank you!