When your Metin2 server lags
Lag can come from the player's connection, a single core, MySQL or the disk. Measure which one it is before you start changing settings.
Before you change anything, get the basics for every lag report: what time it happened, which channel and map, how many players were affected and what they were doing (walking, fighting, trading, storage, login). Without that you're guessing. Then change one thing at a time and measure again. If you tweak CONFIG, MySQL and kernel settings all at once on a hunch, you won't know what fixed it, and you often end up with a new problem on top.
Player or server
That's always the first question. If everyone on a channel lags at the same moment, it's the server. If only a few players lag while others on the same map play fine, it's usually the network in between.
Everyone looks at ping, but packet loss matters more. Metin2 runs over TCP, so when a packet gets lost the connection waits until it has been sent again. A few percent of loss already feels like rubber banding and freezes, even with a perfectly fine ping.
Have the affected players run WinMTR or pathping, which comes with Windows. From the server towards the player you test yourself with mtr. On FreeBSD you install it with pkg install mtr-nox11, on Debian and Ubuntu with apt install mtr-tiny. Then run:
Loss that starts at one hop and stays all the way to the last one is real. Loss on a single hop in the middle, with 0 % again on the hops after it, is harmless, because lots of routers answer these test packets with low priority. If it starts at the very first hop, it's the player's Wi-Fi or router. If it starts right before your server, talk to your host.
If only the picture stutters but characters move normally and hits land on time, it's often not the server at all but the player's graphics, for example in a packed market. And if suddenly nobody can connect, that can be an attack. That's covered in Metin2 DDoS protection.
CPU per core, not the average
This is the one most people miss. A core (one game process) runs its game world mostly in a single thread, so in practice it uses one CPU core. A box with eight CPU cores can lag at 15 % total load because one game core keeps its CPU core at 100 %.
On FreeBSD:
top -P shows every CPU core on its own, top -H -o cpu the threads sorted by CPU, and ps -auxr | head the processes by CPU. On Linux we just use htop. The CPU cores are at the top, and the H key toggles threads on and off:
A game process sitting at 90 to 100 % all the time (WCPU on FreeBSD, %CPU on Linux) is at its limit. To see which channel and core it is, check its working directory, using the PID from top instead of 4182. On FreeBSD:
On Linux:
The fix is splitting the maps better. Which maps a core runs is set in its CONFIG under MAP_ALLOW. Starting villages, popular grinding maps and dungeons with lots of groups go on different cores, don't stack them on one. A map can only be on one core per channel. Restart the cores you changed, ideally during maintenance for the whole channel. Running more game cores than you have CPU cores doesn't help when they're all busy at the same time anyway, and the DB core and mysqld need CPU too.
MySQL and the log tables
All channels lagging at once, mostly while saving, trading, logging in or opening the storage, and mysqld near the top in top? Then the database is holding things up. Check what's running right now:
Lots of queries in Waiting for table level lock or Locked means MyISAM tables are waiting on each other, because MyISAM locks the whole table on every write. To find the slow queries, turn on the slow query log:
Leave it on for an evening with lag, then let mysqldumpslow sum up the file by total time. The path comes from the last query:
Something we'd look at on pretty much any server is the log database. With a lot of server files it just keeps growing, because the cores write trades, drops, commands and logins into it. Tables with millions of rows slow down queries, eat disk space and make every backup take longer. The biggest ones:
Don't delete millions of rows in one go, that locks a MyISAM table for a long time. We'd rather swap the table for an empty one. The rename is a single step, and after a brief moment the cores keep writing into the new table. Example for the table log:
Back up the old one with mysqldump log log_2026_11 | gzip > log_2026_11.sql.gz and remove it with DROP TABLE. If you only want the old rows gone, delete in small batches, DELETE FROM log.log WHERE time < NOW() - INTERVAL 30 DAY LIMIT 50000; a few times during a quiet hour. Column names differ between tables and server files, so check with DESCRIBE first.
About buffers: a lot of older files use MyISAM, where key_buffer_size keeps the indexes in memory and the operating system caches the data. For InnoDB the one that matters is innodb_buffer_pool_size. As a starting point for an 8 GB server that also runs the cores, this goes into the [mysqld] section of your my.cnf:
Don't give MySQL more than you actually have free, the cores need their share. A server that starts swapping lags far worse than one with a smaller buffer.
Disk, RAM and steal time
An overloaded disk mostly slows down MySQL, so again every channel at once. On FreeBSD:
On Linux (iostat is in the sysstat package):
If %busy or %util stays close to 100 % while players lag, it's the disk. Usual reasons are huge log tables, backups during peak hours, core dumps after crashes and syslogs that grow with every error. A full disk is even worse: MySQL can't write anymore and the cores hang or crash.
Change the path to wherever your server files live, on FreeBSD that's often /usr/home or /usr/game, on Linux /home or /opt. And if syserr writes the same message on every loop, the writing alone costs performance.
With RAM it doesn't matter whether swap is in use, it matters whether pages keep getting moved in and out. When that happens, the cores freeze for seconds. On FreeBSD:
On Linux:
Watch pi and po in vmstat on FreeBSD, si and so on Linux. Anything above 0 all the time means you're short on memory. Who is using how much works the same on both systems, the rss column is in KB:
If the lag gets worse over several days, disappears after a restart and one core keeps growing in the meantime, some system or quest grabs memory and never frees it. A regular restart during maintenance hides that, it doesn't fix it. Track the memory of your cores for a few days and you'll see which one grows.
On a VPS there's also steal time. You share the physical CPU cores with other customers, and when a neighbor is busy your machine gets less CPU time than it asks for. Linux shows it as st in the %Cpu(s) line of top and as the st column in vmstat 1. If that's regularly above a few percent, your cores lag and it's not your fault. FreeBSD's top has no value for it, a hint is load going up without more players. The only real fix is a plan with dedicated CPU cores or a dedicated server.
Lag at fixed times
Lag every day at the same time? Look for scheduled jobs first, and on Linux also in the folder /etc/cron.d/:
On FreeBSD, /etc/crontab runs the daily periodic jobs at 3:01 server time, which is often UTC. Among other things they scan the file systems for the security report, and that puts load on the disk. Backups with mysqldump --lock-all-tables lock every table until the dump is done, so no saving and no trading for that long. Move that kind of job to the quietest hour of your server. How to keep the lock short is in Metin2 server backup. Website rankings that send heavy queries to player every few minutes and OPTIMIZE TABLE during peak hours are worth a look too.
Lag only at the evening peak is a different story, that's usually the map split again. Put the player count per channel next to the CPU of each core at that moment and you see which core has too many popular maps. Events work the same way: a boss or metin stone event pulls every player onto one map, and so onto one core.
Quests and mobs
Quests run inside the core. A timer that fires every second for every player, or an expensive check on every kill, adds up to thousands of Lua calls per second with 300 players online. In your quest folder:
Look for one or two second timers running per player, and when kill blocks that aren't limited to specific mobs, because those run code on every single kill on the server. If your source lets Lua run database queries, keep them out of blocks like that, the core waits for the answer. Recompile the quests afterwards, see compiling quests.
For mobs, check the regen files of the map: regen.txt, plus boss.txt, stone.txt and npc.txt depending on your files. Classic mistakes are very short respawns for big groups, counts that are too high and duplicate lines after merging files. Lines with a respawn time in seconds:
Duplicate lines:
One overcrowded map drags down every other map on the same core.
See lag in your history with Servergilde
The free monitoring on the Servergilde platform records players per channel, CPU and memory of every core, swap and disk usage every minute, so you can see whether lag follows the player count, a time of day or one core. If a partition goes above 90 % or swap stays above 50 % for ten minutes, you get an alert on Discord, and the free server check looks at your database, ports and backups every day. If you get stuck, we can find the cause as a fixed price job, or you create a free account and start with the monitoring.
Frequently asked questions
Why does my server lag when the CPU is barely doing anything?
top -P on FreeBSD or htop on Linux, then spread the busy maps over more cores with MAP_ALLOW.Is it the players' connection or my server?
pathping, or test from the server with mtr -rwc 100, and look at packet loss rather than ping.Can a VPS make my server lag even if I did nothing wrong?
st in top or vmstat 1. If it's regularly above a few percent, only a plan with dedicated cores or a dedicated server helps.How do I get rid of a huge log table without locking the server?
CREATE TABLE log.log_new LIKE log.log; and swap it in with RENAME TABLE log.log TO log.log_2026_11, log.log_new TO log.log;. Then back up the old table with mysqldump and drop it.