Performance

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(General Tips)
Line 115: Line 115:
 
|158 prims
 
|158 prims
 
|-
 
|-
|Hosted Parallels Virtuozzo 4.5
+
|Hosted Dedicated OVH
|Win/Net (32 run)
+
|Suse 12.2
 
|0.7.0.2 (D2)
 
|0.7.0.2 (D2)
 
|420Mb total, incl OS, Opensim and MySQL
 
|420Mb total, incl OS, Opensim and MySQL
|i7 Quad 950 (Bloomfield) 3.07GHz, 8 Core, 2Gb RAM, 0-2% Avg Load
+
|i7 Quad 950 (Bloomfield) 3.07GHz, 8 Core, 24Gb RAM, 0-1% Avg Load
 
|16 regions (4x4 mega-region)
 
|16 regions (4x4 mega-region)
 
|<6 users
 
|<6 users

Revision as of 08:39, 30 September 2012

Contents

Introduction

OpenSimulator performance is a very complex issue. Performance can be affected by any number of things, including the number of prims on a region, number of regions, number of avatars, network quality between server and viewer, network quality between simulator and grid services, etc.

We can break down a performance discussion into simulator issues (e.g. script performance, region database performance) and grid issues (chiefly scaling services such as asset, inventory, etc to serve more simulators and users).

General Tips

  • Where at all possible, don't assume something is a performance bottleneck, measure it! You might think your asset database is large, for example, but even large asset database seldom cause real issues.
  • Make as many objects phantom as possible. Phantom objects do not need to be tested for collisions with avatars and other objects, reducing physics frame time and increasing performance.
  • Make as few objects subject to physics (e.g. falling under gravity, movable by other avatars) as possible. Physics objects need a lot more collision testing than ordinary non-phantom objects.
  • It can be hard to perform measurement at the moment since not a lot of tools exist. However, one such is pCampbot which is bundled with OpenSimulator. This can instantiate a number of simultaneous libomv clients on a simulator that can take certain actions such as clicking things and bouncing aroud. Apects of it (e.g. appearance) are currently rather buggy and generate a lot of logging guff.

Simulator

Hardware Requirements

Unfortunately, this is a very difficult question in light of all the factors mentioned in the introduction.

However, we can say that OpenSimulator does not run well when it only has access to a single CPU core - you should regard a dual-core machine as the minimum.

Below are some examples of hardware people use/have used. Please feel free to add to the list, or to add any reports to the performance studies and blog posts section. These are examples to help you in your selection, not recommendations.

Object Parts ~= # prim

Sensors and Timers are generally more intensive then regular scripts, so please specify quantity of each.

Description Operating System (please add Mono version if appropriate) OpenSimulator version RAM/AVG_USE_% CPU #/type of regions # simultaneous avs #scripts/timers/Sensors Location #objectparts
hosted Xen VPS Ubuntu Intrepid (8.10) Unknown 540MB/? 1x quad-core 2.5GHz Xeon (L5420) 1 region + 9 voids generally 1-2 few Knifejaw Atoll & surrounding on OSGrid ?
hosted Xen VPS Ubuntu Jaunty (9.04) Unknown 360MB/? 2x dual-core 2.0GHz Xeon (5130) 1 void generally 1-2 none Knifejaw Road on OSGrid ?
Dedicated Server from A+ Windows Server 2003 Unknown 1 Meg 1x single-core 2.8GHz Celeron 2regions per server 6 at once with no issues Waterfalls, texture anims, window texture switchers, lots of sound loops Pleasure Planet Welcome center & Region Pleasure Planet in OSGrid 20000 prims per region
Amazon EC2 "high-CPU medium instance" (Xen VM) Windows Server 2003 Unknown 1.7GB 1x dual-core 2.3GHz (Intel E5345) 1 region with sailing race course 7 avs, 4 in boats scripted start line Castle Rock, OSGrid
Dedicated Server from simhost.com SuSe 11.2 x64 Unknown 8gb / 50% 4x Core2Quad Q9300 2.6ghz 1 region (Wright Plaza) uses approx 4gb ram 20-25 users Freebie Stores / Meeting Center / Video Theater @osgrid.org Heavy Use Sim 17500 prims aprox 1500 scripts
Home machine Windows XP SP3 0.7.0.1 (Diva r13558) 3GB / 15-40% incl. Opensim and MySQL 4x Core2Quad Q6600 2.4 GHz. Use: generally, 0-10% 11 regions 1-6 users Many scripted objects (1934 scripts) Condensation Land 38,065 prims
Home machine Ubuntu Lucid 10.04 (32 bit pae) 0.7.0.1 (Diva r13558) 160Mb no users, add 5Mb/user incl Opensim and MySQL I7-920 (dual threaded quad core), 3.8Ghz, 6Gb RAM, 0-10% Load 4 regions (Diva default config) 1-4 users (approx 20Kb/sec bandwidth/user) Few scripted objects (<10) Mars Simulation- Based on Erik Nauman's Open Blackboard 158 prims
Hosted Dedicated OVH Suse 12.2 0.7.0.2 (D2) 420Mb total, incl OS, Opensim and MySQL i7 Quad 950 (Bloomfield) 3.07GHz, 8 Core, 24Gb RAM, 0-1% Avg Load 16 regions (4x4 mega-region) <6 users vehicle scripted objects (<5) Metaverse Sailing <1000 prims
VPS Debian Lenny 5 (mono 2.4.2.3) OSgrid 0.7.1 (Dev) cd4d7a7: 2010-10-15 655MB average out of 1722MB RAM, incl. MySQL Intel Quadcore 2.5 Ghz (1 core assigned to vps) average use: 40-45% 20 regions <4 users about 20 different light scripts, but we're also experimenting with heavier HUD scripts (timers, lots of ll(Get/Set)PrimitiveParams and large lists) and custom IRC relay Phoenix Rising Isles on OsGrid 3727 prims

Database

By default, OpenSimulator is configured to use the SQLite database. This is very convenient for an out-of-the-box experience since it requires no configuration. However, it's not designed for heavy usage, so if you build very quickly or have more than a few people on your simulator then you will start to see performance issues.

Therefore, we recommend that you switch to MySQL as soon as possible. This will provide a much better experience but will take a little bit of work to set up.

Unfortunately, tools for migrating OpenSimulator SQLite data to MySQL are currently limited. Migration is also possible by saving OARs/IARs of your data from sqlite and loading them up once you've reconfigured to use MySQL.

There is also a database plugin for MSSQL but this is not well maintained between OpenSimulator releases.

In standalone mode, both services and the simulator itself can use SQLite. In grid mode, SQLite is only supported for simulator data - the ROBUST instances must use a MySQL (or MSSQL) database.

In general a single MySQL instance for the ROBUST services instance will serve small, medium and even large grids perfectly well - it's a configuration that's widely used for even quite large websites.

Configuration tweaks

There are a couple of OpenSimulator configuration tweaks that you can do to significantly improve script loading performance in certain situations. These tweaks can be made in your OpenSim.ini config file. These apply to current OpenSimulator development code (0.7.3-dev) and may also apply to 0.7.2, though certainly not any earlier.

Set DeleteScriptsOnStartup = false

[XEngine]
DeleteScriptsOnStartup = false

This means that OpenSimulator will not delete all the existing compiled script DLLs on startup (don't worry, this setting doesn't touch the actual LSL scripts in your region). This will significantly improve startup performance. However, if you upgrade OpenSimulator in place (e.g. you regularly update your installation directly from development code) then you may occasionally see problems if code changes and your previously compiled DLLs can't find their old references.

In this case, you can either set DeleteScriptsOnStartup = true for one restart in order to clean out and recompile script DLLs or you can manually delete the relevant bin/ScriptEngines/<region-uuid>/*.dll.* files, which will force OpenSimulator to recompile them. You could also delete the entire bin/ScriptEngines/<region-uuid> directory but this would lose all persisted script state (which is kept in the <script-item-id>.state files).

Set AppDomainLoading = false

[XEngine]
AppDomainLoading = false

By default, OpenSimulator loads every script DLL into its own AppDomain. If this is set to false, then all scripts are loaded into OpenSimulator's default AppDomain instead.

This will significantly improve script startup times and reduce initial per-script memory overhead.

However, setting this to false will also prevent derezzed script DLLs from being removed from memory (only whole AppDomains can be unloaded). This might cause an OutOfMemory problem over time, as avatars with scripted attachments move in and out of the region. Whether this is a problem for you will depend on factors such as the avatar population of your grid.

In addition, Windows users have reported script loading problems with AppDomainLoading = false, though I (justincc) haven't been able to replicate this with current OpenSimulator code on my WindowsXP machine.

Grid

Scaling a grid is a very complex task and only for the very technically inclined. It is also an area under active investigation. The advice below will change considerably over time as OpenSimulator and its environment changes and we learn more about perfomrnace issues.

When would you start to meet grid scaling issues? As an extremely rough and really quite arbitrary and pessimistic rule of thumb, you will probably start to have to think about things when you exceed 50 regions containing a large number of prims or 50 simultaneous users with large inventories. But this will very a tremendous amount depending on your situation. If you have thousands of regions with very few prims that much more supportable than 50 regions with 45000 prims each.

You are likely to encounter issues in two areas - database and services.

Database

Assets

The problem

Due to the architecture of distributed architecture of OpenSimulator, where regions are running on a number of different machines over a network, it's extremely hard to identify assets that are not in use and hence can be deleted. Equally, the fact that assets are immutable leads to continual growth in the asset database.

In theory, one could identify unused assets if one could identify all references in simulators and in user inventory. However, this is extremely hard to do where machines are distributed over a network. If a grid only has a few simulators all running on machines that are controlled by the same entity running a grid, then it becomes a little more tractable but even then would almost certainly involve significant downtime. No public tools exist yet to achieve this.

Asset deletion would be easier for a one simulator grid or a standalone. However, even code to implement asset deletion on standalones has not yet been implemented and would certainly require significant simulator downtime.

A promising area of research involves improving OpenSimulator's recording of asset access times (e.g. recording access periodically). Then assets which aren't accessed for a long time (e.g. a year) could be deleted or moved to cold storage (e.g. DVD). One is left with the problem of not deleting assets permanently cached by simulators but perhaps this could be solved by the simulators occasionally 'pinging' the asset service with notification of what assets they cache.

Another step to reduce asset database size is to eliminate duplicate assets by hashing. There is an experimental development asset service for this. Third party services such as [SRAS] also do this.

Possible solutions

  • Do nothing. MySQL can store a very large amount of data before encountering issues - it's used for extremely large websites and other applications after all. This assumes you have the disk space.
  • Use an external asset service such as [SRAS]. SRAS, in particular, is a third party asset service that does deduplication, asset compression, and stores assets on disk rather than in a database. It also has some nice features like preventing assets being served without deleting them. It's used by OSGrid, for instance. However, it does work in a different way from the bundled OpenSimulator asset service (e.g. backup of on-disk assets involves some extra steps compared to just backing up a database). It also requires a migration step that may take a considerable time if you have an existing asset collection.
  • Save every region to an OAR and every user's inventory to an IAR. We believe this is equivalent to finding all referenced assets and can be done manually. However, it's very laborious for installations with a large number of users and requires grid downtime. Tools could be written to improve this, particularly in systematically saving all user inventories to IARs.

Other databases

The space required by assets far outweighs other data storage requirements so only asset data is generally an issue.

Services

The problem

The other problem is with handling the number of requests to services when the number of simulators and users grow. The asset service isn't generally a problem since simulators cache all assets used, though it can form a bottleneck on OAR upload. The biggest issue is generally caused by users, chiefly due to inventory access and perhaps update last user positions in the GridUser service (and database table).

ROBUST uses an embedded [C# HttpServer]. Performance comparisons to other Webservers (e.g. Apache) have not been carried out (?) but responses appears to be much, much slower. As it has been discontinued it's also rather unlikely to have it's performance improved. In future, OpenSimulator may embed a different HTTP server but this is extremely unlikely in the short term.

Possible solutions

  • Split up services. By default, ROBUST runs every service in one process. However, because services are separate from each other, you could run some services (e.g. inventory in one ROBUST instance and other services (e.g. asset) in a different instance, even if they both point to the same database. Because the embedded C# webserver is slow and possibly not very concurrent, this can achieve significant performance improvements even if all ROBUST instances are running on the same machine.
  • Instantiate extra ROBUST copies of problem services (e.g. inventory). Because services are stateless (akin to a webservice), you can load balance requests between multiple instances using a reverse proxy such as nginx. Again, because the embedded webserver is probably inefficient, you can achieve performance improvements by running multiple copies of services on the same machine.
  • Use an external service based on a more efficient HTTP server, e.g. SRAS (asset service only) or SimianGrid. Please be aware that SimianGrid uses a different set of simulator <-> service protocols than used by ROBUST. The necessary SimianGrid adaptors are part of the core OpenSimulator distribution.
  • Write your own services to run on an external webserver. This wouldn't be too hard to do in something like PHP, though one would need to work out the currently undocumented wire formats. If you do this, please do let us know :)

Performance studies and blog posts

These provide some interesting data on the performance limitations of OpenSimulator at various points in time.


Personal tools
General
About This Wiki