Okay, so you got your Codius Host up and running and you are most likely smiling after spending tons of time getting it to work. Speaking to others you are most likely saying stuff like "I set up a server with 32 GB so i can host 64 contracts as 1 contract is 512 MB".


However i'm sorry that i have to disappoint you though.

Looking at https://codius.example.com/memory, with codius.example.com being replaced with your own server, you can see the actual memory allocation now.

As a default all Codius hosts are only allocating 75% of their memory to hosting contracts. This effectively means that with a 32 GB memory server you are only able to host 48 contracts as only 24 GB are able to be utilized.

Why is this ? - to run a server the operating system of course need some ressources. Depending on how much your server does i would recommend 512 MB for low utilization and 1 GB for servers with higher utilization. But what about the remaining 7 - 7.5 GB ?

To increase the memory cap you will need to change some settings for codiusd.

Go to

/etc/systemd/system

You will see the default config you most likely put in:

[Unit]
Description=Codiusd
After=network.target nss-lookup.target
[Service]
ExecStart=/usr/bin/npm start
Environment="DEBUG=*"
Environment="CODIUS_PUBLIC_URI=https://codius.example.com"
Environment="CODIUS_XRP_PER_MONTH=10"
WorkingDirectory=/usr/lib/node_modules/codiusd
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=codiusd
User=root
Group=root
[Install]
WantedBy=multi-user.target

In here we want to add a new line:

Environment="CODIUS_MAX_MEMORY_FRACTION=0.97"

This setting tells Codius to use up to 97% of the available memory which with 32 GB  of ram means ~31 GB of ram. This means we are effectively using all the ram besides the operating system requirements/recommendations.

The settings file should look like this:

[Unit]
Description=Codiusd
After=network.target nss-lookup.target
[Service]
ExecStart=/usr/bin/npm start
Environment="DEBUG=*"
Environment="CODIUS_PUBLIC_URI=https://codius.example.com"
Environment="CODIUS_XRP_PER_MONTH=10"
Environment="CODIUS_MAX_MEMORY_FRACTION=0.97"
WorkingDirectory=/usr/lib/node_modules/codiusd
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=codiusd
User=root
Group=root
[Install]
WantedBy=multi-user.target

Afterwards save the file and we are ready to restart codius with the new settings

Run the command

systemctl stop codiusd

You will instantly see the system complaining that codiusd.service has been changed on disk.

Run

systemctl daemon-reload

to reload the file.

Restart Codiusd again with

systemctl start codiusd

and you can now on see on https://codius.example.com/memory that you have more memory allocated to your server and you are now able to host more contracts than before!

Let the contracts roll in :)