In my last article, I wrote how to use the tmpfs from Linux to speed up the local SQLite databases that FreeSWITCHtmpfsuse the tmpfs from Linux to speed up the local SQLite databases that FreeSWITCH uses for operation.
What happens when you are not using SQLite? As a cluster, Is there a way? The short answer is yes. This is more a database specific speed up, but because the nature of the use case, it is very specific for FreeSWITCH and FusionPBX.
FreeSWITCH FreeSWITCH Database
The FreeSWITCH database is the one that the FreeSWITCH daemon uses to keep the sate of the operations. The good thing is that this database size is small; the bad thing is that it must be very responsive. This seems to be a good job for SQLite. By default, SQLite databases are stored in the /var/lib/freeswitch/db directory, but since FreeSWITCh in High Availability or Load-balanced mode (with FusionPBX) needs a shared database, the SQLite approach will not work.
FreeSWITCH supports external database; it has native PostgreSQL support and any other external through the ODBC engine. MariaDB or MySQL support is through the ODBC engine.
After applying the change I am suggesting, You will notice your PBX faster. Especially when doing internal calls.
I will talk how to make this happen with MariaDB/MySQL
Speeding up FreeSWITCH Database with MariaDB or MySQL
MariaDB and MySQL manage its database by creating a directory with the database name inside the /var/lib/mysql directory. Therefore, the freeswitch database path is /var/lib/mysql/freeswitch.
Because of this database nature, its size is quite small. You will need to check your own system, but in my case:
- a simple 10 extensions PBX, it is 100 MB
- a 10 server load balanced cluster with 2000 registered, it is 1 GB
The trick here is to create a tmpfs with enough size for your growing. The easiest way is by adding the following line in the fstab file.
tmpfs /var/lib/mysql/freeswitch tmpfs nodev,nosuid,noexec,nodiratime,size=100M,uid=27,gid=27,mode=0755 0 0
What about the PostgreSQL?
First, I am not a PostgreSQL expert. Please verify this advice. PostgreSQL does not use the database name when creating the database (but it does actually use a directory for a database). The first thing would be to find the OID number, this can be done with the following SQL query: SELECT datname, oid from pg_database.
The path could change, but in the system I reviewed, it was in /var/lib/postgresql/10/main/base. You will find some directory names with the OID's as the names.
You can do the same MySQL approach once you have the route.
Side Effects of Speeding Up Databases with Tmpfs
So far, the only side effect I have found is that you can not drop the database.
Good luck!blog comments powered by Disqus