MyBB Community Forums

Full Version: Multiple Web Servers/Instances - Configuration?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello:

So I am quite impressed with MyBB 1.6.12 and have decided to stick with it for a number of forums.

I have a few questions about running multiple web instances to "scale out." In my experience, forums software such as this that runs background tasks and has caching tends to run into problems when you run more than 1 web instance on the same site. For example, two web servers using one database server.

I have my MyBB installation running happily in Windows Azure shared web sites. I have two instances running to ensure there is no downtime (Azure only guarantees 99.9997% uptime if using two or more instances).

Multiple web instance configuration?
My primary concerns are:

* What happens with the background "tasks" running in the PHP site across multiple instances? Is there a history of duplicate emails or mass mailings, database maintenance, etc?

* Temp files per instance? I am not that fimiliar with PHP and MyBB to know if there are special temp files created per instance and may corrupt if read by another instance (see shared file system below).

They all share 1 file system
The way that these shared web instances works in Azure is that there is 1 common file system shared across all web instances (think DFS). The downside to this type of configuration is that I am not able to specify configuration files for each web instance - they all share the exact same configuration files.


And btw: yep, I even have the full Google SEO plugin enabled on IIS: www.cudaminers.net - I posted a gist of the web.config I created for all redirects on IIS if anyone is interested:

https://gist.github.com/eduncan911/9864466

Thanks!
~E
MyBB stores all the cache in the database as well as the task run times and mail queues, so as long as both instances are sharing the one database instance it'll be fine.

Also a question, what are you doing for your database? Is that running on another of Azure's services or are you running MySQL from the shared file system?

If you're running it from the shared filesystem, I'd highly recommend you stop that (Assuming both servers are running at the same time?) and instead set up a separate instance on each server and setting them for for HA with clustering.
Thanks!

Ok, that answers the caching concern - though I am wondering what is even being cashed. And, if that is the most performant (to use a DB instead of file system, where both web servers would naturally share the common file system). In my experience, you can't beat serializing data to disk local to the web servers in a cluster. Is there Memcached options for MySql to get it out of the DB?

About the tasks though, here's more of what I was asking:

* Mass Mailer Task for example.
There are two web-instances; therefore, there are two mass-mailing tasks running. This would be setup to cause a race condition with two tasks running the same queue. What happens when I insert a queue of say 1000 emails to send (10 at a time). How is the locking handled on the database side to guarantee only 1 task gets the record set? I know MySql has a nice INSERT or UPDATE to handle inserting it. But I am not too familiar with MySql's row locking to select and update a record, preventing any other instance from accessing that row. It is MySql 5.6 running InnoDB (the default engine in MySql 5.6 now, btw).

For example, SQL Server has a nice trick to where I can update a row (which locks that row) and grab the output of that row into a #temp table - where I return results. I use this trick a lot in production to update a Timestamp/status of a row, and grab the rows that I updated all in one shot.

And no, the MySql server is running on a dedicated "small" VM behind the scenes. Which sucks - cause Azure occasionally "performs maintenance" on the Vm infrastructure and reboots them. This is why they say you have to have two running to guarantee 99.997% uptime. My issue is I don't plan on setting up a MySql cluster service - I don't think that is free from MySql (Enterprise stuff).
(2014-04-11, 03:06 PM)eduncan911 Wrote: [ -> ]* What happens with the background "tasks" running in the PHP site across multiple instances? Is there a history of duplicate emails or mass mailings, database maintenance, etc?
See inc/functions_task.php if you're really interested on how tasks run.
By default, they're called by users accessing task.php, so you really have nothing to worry about since you could easily have concurrent tasks running on a single server setup.

But if you really want to, you could remove the task.php and setup a cron on one of the servers to run background tasks.

(2014-04-11, 03:06 PM)eduncan911 Wrote: [ -> ]* Temp files per instance? I am not that fimiliar with PHP and MyBB to know if there are special temp files created per instance and may corrupt if read by another instance (see shared file system below).
If the forum is on a shared file system, there shouldn't be any issues.

(2014-04-14, 01:18 AM)eduncan911 Wrote: [ -> ]Ok, that answers the caching concern - though I am wondering what is even being cashed. And, if that is the most performant (to use a DB instead of file system, where both web servers would naturally share the common file system). In my experience, you can't beat serializing data to disk local to the web servers in a cluster. Is there Memcached options for MySql to get it out of the DB?
DB is probably better to avoid potential locking issues with disk based storage.
If you're referring to MyBB's "data cache storage", it can be placed in memory caches, but it's pretty useless IMO. At the very most, it just saves a single query per page load, which, since it's a static query, is likely to be in the MySQL query cache anyway.

(2014-04-14, 01:18 AM)eduncan911 Wrote: [ -> ]How is the locking handled on the database side to guarantee only 1 task gets the record set? I know MySql has a nice INSERT or UPDATE to handle inserting it. But I am not too familiar with MySql's row locking to select and update a record, preventing any other instance from accessing that row.
MyBB has a locking mechanism on the tasks table, but it isn't atomic. Actually, you'll find this to be the case throughout MyBB, which was designed mostly for the non-transactional MyISAM storage engine.
In other words, a race condition is possible, but rather unlikely.

(2014-04-14, 01:18 AM)eduncan911 Wrote: [ -> ]And no, the MySql server is running on a dedicated "small" VM behind the scenes. Which sucks - cause Azure occasionally "performs maintenance" on the Vm infrastructure and reboots them. This is why they say you have to have two running to guarantee 99.997% uptime. My issue is I don't plan on setting up a MySql cluster service - I don't think that is free from MySql (Enterprise stuff).
A master-master replication setup could work, if that really interests you.
The MySQL-cluster is GPL though: http://dev.mysql.com/downloads/cluster/