@Nikola-Milovic This is a very broad question, so I’ll summarize a few highlights here.
You’re on the right track on initialization. At server startup we’ll observe registered RPC functions, before/after hooks, event handlers, matchmaker hooks, match handlers and so on - these are mapped, cached, calls to them might be wrapped in interceptors that track metrics (throughput, execution time, data in/out etc) and more. If you want minute detail here the best path is to have a look through the server code, remember Nakama is open-source.
That said I’d recommend not worrying about the server internals unless it’s absolutely unavoidable. We’ve designed the server to scale well, and are constantly improving every aspect of its internals and feature set. Time spent executing match handler and RPC functions will almost always eclipse the cost of the server’s own internals, so spend most of your time on the former.
Focus on writing the best version of your RPC functions and match handler code, then optimize what you need as you go along. For match handlers you should think in terms of individual match units - build each match as if it’s the only one that will be running on the server, logically speaking, and build it as an isolated unit. In practice the main consideration is to avoid using global fields and put everything you need in the match state. Beyond this general best practices apply: avoid allocating more than you need, don’t copy if you can avoid it, no O(n^2) algorithms etc
You can always come back with specific questions if you run into issues, the forums are here to help!