Choosing the right server configuration and predicting operating costs for running a UNA-powered site may be important for your business strategy planning. This guide may help you choose correct hosting and plan for scale.
Please remember that this is a simplified approximation for the default UNA setup with standard modules only. The real site can have many more modules from 3rd-party developers (which can affect on-site load, space requirements, etc.) or can be focused on resource-intensive tasks that may call for a different estimation (i.e. video conversions, high-storage sites like pro-level photo sharing, etc.)
How to calculate load and choose proper hardware.
The load is very dependant on the number, purpose, functionality and quality of installed modules and the site template. Therefore it is almost impossible to predict it beforehand. But if you have a sample setup of the desired site configuration or pre-production setup on the web server, it is possible to at least predict the memory usage.
To do it install "Profiler" module, this module shows different timings at the bottom of every page for site administrator (by default). Try to open different pages and watch for memory usage and page execution time.
Try open different pages and measure average "Memory" and "Time" values. Let's assume that it is 20Mb for memory usage and 0.5 seconds execution time. Then, if you have a web server with 4G RAM (for example) the web server is capable to handle:
4G - 1G (for system usage) / 20 Mb ~ 150 simultaneous requests.
Please note, that simultaneous requests aren't a number of online users. Users make requests to the server one time in several seconds or a dozen of seconds.
If it is a mostly static site (without much dynamically changing content like the Messenger, Shoutbox, Rocket.Chat, etc) then one request in 30 seconds from one user is likely. In this case, the server is capable of handling the following number of online users:
30 (average seconds per one request from one user) / 0.5 (our average "Time" value) * 150 (simultaneous requests) = 9000 online users
If it is a dynamic site (with the messenger, active timeline, notifications, etc.) like most UNA sites, 1 request from one user every second on average is likely. In this case, the server is capable of handling the following number of online users:
1 (average seconds per one request from one user) / 0.5 (our average "Time" value) * 150 (simultaneous requests) = 300 online users
As you can see a dynamic site require 30x more resources than a static site.
This is a very rough calculation which considers only server memory usage, while CPU usage is not counted at all. You may have CPU-intensive usage and low memory load and vice versa. For example, video conversions may cause very high CPU usage.
How to calculate load and choose proper hardware for the database server
DB server is dependant on many factors and can not be precisely planned until the site use patterns are observed in production. Just make sire to follow these guidelines:
- Tune MySQL settings for your needs, recheck settings as your database grows and the load increases. Try this tool to check and tune your MySQL settings: http://mysqltuner.pl/
- Installing more RAM can help a lot. Refer to the first advice to see if you need more RAM.
- Use InnoDB DB engine instead of MyISAM if you have high load.
- Store database tables on SSD disks, for the better performance you may need to tune MYSQL especially for SSD disks. (Note, that UNA Cloud servers work on SSD disks only).
- If the load is too high, you may need a server cluster for your MySQL DB.
How to calculate database and files storage needs
Storage varies depending on number and types of installed modules. The better method is to start site and when you will have a number of users, calculate average data size in DB and on Disk and multiply this values on some number of users you need going to plan for.
In the following calculations, we are using some sample UNA setup. The site has only 9 users, all standard modules are installed and almost every user has some content (text content, photos, videos and sounds) in different modules.
Let's assume that we need to calculate future storage for 100 000 users.
- Current size: 1.5 Mb
- Number of users: 9
- Average DB space per user: 1.5 Mb / 9 ~ 0.167 Mb
Approximate DB Storage required for 100 000 users
100 000 * 0.167 Mb = 16700 Mb ~ 16 Gb
- Current size: 374 Mb
- Number of users: 9
- Average DB space per user: 374 Mb / 9 ~ 41Mb
Approximate Disk Storage required for 100 000 users:
100 000 * 41 Mb = 4 T
Note, that UNA supports remote storage, so you can use, say, AWS S3 storage for quick and price-efficient media storage.
Hosting Server Costs
As a rule of thumb, dedicated servers would be more cost-effective for large sites with a predictable load. You can get a configuration with more RAM, storage and better CPUs compared to a similarly priced Cloud-based server. On the other hand, Cloud-servers can be scaled up more easily and it is possible to start with a smaller instance, scaling up as required - this approach may prove to be more cost-effective for a small to medium community site.
Another consideration is that SSD-based servers will always cost significantly more than a HDD-based ones, so it is best to use SSD-based servers only for the web-server and the database while leveraging external storage for media files.
For a rough estimate, let's take a community with a few active modules, messenger, albums and timelines enabled, but no specific focus on video sharing, file storage, etc.
$100/mo - UNA Cloud4
$50/mo - dedicated server
At this size only a few "online" users are present at any given time, so a basic server like UNA Cloud 4 would be sufficient. On-server storage can be used for the database, and media storage needs would be in the range of 40Gb, so the media can also be stored on site. A dedicated server with similar specifications woudl cost about $60. Note, that UNA Cloud comes with included UNA Pro plan, so this choice may still be preferable.
$150/mo (UNA Cloud8) + $20 for AWS S3
$100/mo - dedicated server with 2 disk arrays.
At this size only you may expect about 20-30 online users during peak times. Still, on-server storage can be used for the database. While at higher numbers average storage uptake tends to go down, we would still recommend connecting remote storage at this scale - you may need up to 500Gb-1TB, which is likely to be relatively expensive with an on-server SSD.
A dedicated server with similar specifications would cost about $120 and may include a disk array for media storage.
$150/mo (UNA Cloud8) + $100 for AWS S3
$150/mo - dedicated server with 2 disk arrays, extra RAM and upgraded CPUs
A community with 100K members may result in 200-300 online users during peak times. Database will take only about 15-20Gb, so it's best store it on-server. Media may take 4-5TB, so it is definitely best to leverage remote storage.
A dedicated server with similar specifications would cost about $200, as it will require RAM and CPU upgrades as well as multiple disks for media storage and redundancy.
$200/mo (UNA Cloud16) + $500 for AWS S3
$150/mo - dedicated server + $500 for AWS S3
When you reach a million-members stage, some of the costs "per members" can be reduced significantly. Typically remote storage pricing for higher allocation is lower and you can pre-order fixed-price servers. Usage patterns become more established and it is possible to optimise the site to meet specific requirements for best efficiency. Even with 2000-3000 online users during peak times the site is likely to operate well on UNA Cloud 16 or similar server. The database can still be stored on-server but may need to be separated soon. Media may take up to 50TB, making it difficult to store media on-server even if you're using a dedicated box.
A dedicated server will have to use remote storage, so while you'd need to further upgrade CPUs and RAM, most of the storage disks can be removed.
$1,600/mo (UNA Cloud128) + $3,000 for AWS S3
$1,600/mo - 2x dedicated servers + $3,000 for AWS S3
At ten million members stage, you may be seeing up to 20,000 online users. It is very important to optimise database requests, site configuration, turn off unused features and minimise clutter. UNA Team would be happy to assist with this process.
Cost of dedicated or cloud-based hosting is likely to be very similar at this size, due to the added complexity of the dedicated server setup (you'd likely need to make a 2-3 server cluster).
$9,600/mo (UNA Cloud192 x 3) + $20,000 for AWS S3
$10,000/mo - 2x dedicated servers + $20,000 for AWS S3
Large sites with 100M users or more would likely have to spend a lot more on administration, organisation and other business costs part from direct hosting fees. Single cloud server or a simple dedicated server cluster is likely to be not enough, so we would recommend engage our team or hire a solutions architect to plan an adequate hardware configuration. Web server, database server and storage would require own separate instances (or clusters) and it may be feasible to build an in-house hosting solution.
1 Billion Members