It is often difficult to find the optimal parameter analytically. In this case, if temporary resources allow, you can go through all the possible options, see how good they are and choose the best one.
1000 ms 256 Mb Rules for program design and list of errors in automatic problem checking