| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD: ScoreboardFile</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center><h2><b>ProFTPD: ScoreboardFile</b></h2></center> |
| 11 | <hr> |
| 12 | |
| 13 | <p> |
| 14 | <b>What is the Scoreboard?</b><br> |
| 15 | The <code>ScoreboardFile</code> is used by <code>proftpd</code> for tracking |
| 16 | information for each current FTP session. It is necessary for things like |
| 17 | <code>MaxClients</code>, <code>MaxClientsPerUser</code>, <i>etc</i>. |
| 18 | The utility programs (<a href="../utils/ftpwho.html"><code>ftpwho</code></a>, |
| 19 | <a href="../utils/ftpcount.html"><code>ftpcount</code></a>, |
| 20 | <a href="../utils/ftptop.html"><code>ftptop</code></a>) read the scoreboard and |
| 21 | display its information. |
| 22 | |
| 23 | <p> |
| 24 | Here's how <code>proftpd</code> handles its scoreboard: There is a default |
| 25 | path that <code>proftpd</code> will use for writing its scoreboard |
| 26 | (<code>var/proftpd/proftpd.scoreboard</code>). This default path depends on |
| 27 | how you install proftpd (<i>i.e.</i> if you install from source and use the |
| 28 | --prefix <code>configure</code> option, the default path will be adjusted to |
| 29 | honor your --prefix). However, you can also explicitly tell the daemon what |
| 30 | location to use for its scoreboard using the <code>ScoreboardFile</code> |
| 31 | configuration directive in your <code>proftpd.conf</code>. When |
| 32 | the daemon starts up, it looks to see if there is a scoreboard already there; |
| 33 | if there isn't, it makes a new one. |
| 34 | |
| 35 | <p> |
| 36 | The most common error encountered when opening the scoreboard is: |
| 37 | <pre> |
| 38 | unable to open scoreboard: No such file or directory |
| 39 | </pre> |
| 40 | This usually means that <code>proftpd</code> is trying to open a |
| 41 | <code>ScoreboardFile</code> in a directory that does not exist. Some packages |
| 42 | fail to create the needed directory; this will result in the error message |
| 43 | above. If you cannot find your <code>ScoreboardFile</code>, you should try |
| 44 | explicitly configuring the path to the file to use in your |
| 45 | <code>proftpd.conf</code>, using the <code>ScoreboardFile</code> configuration |
| 46 | directive, and then obtaining debugging output from your <code>proftpd</code>, |
| 47 | to see if the daemon ran into problems using that defined location. |
| 48 | |
| 49 | <p> |
| 50 | In proftpd-1.3.4rc1, a new <code>ScoreboardMutex</code> directive was added. |
| 51 | This file is used as a mutex for starting/ending sessions, for improving |
| 52 | performance under load; see <a href="http://bugs.proftpd.org/show_bug.cgi?id=3208">Bug#3208</a> for the technical details. The default path (usually |
| 53 | <code>var/proftpd/proftpd.scoreboard.lck</code>) for |
| 54 | <code>ScoreboardMutex</code> should suffice. If you need to explicitly |
| 55 | configure a different <code>ScoreboardMutex</code> file, make absolutely |
| 56 | sure that you <b>do not place the file on a networked filesystem</b>. Your |
| 57 | performance will suffer greatly if you do. |
| 58 | |
| 59 | <p> |
| 60 | <b>What's in the Scoreboard?</b><br> |
| 61 | What types of information about each session is tracked in the scoreboard? |
| 62 | What else is recorded in the scoreboard? |
| 63 | |
| 64 | <p> |
| 65 | The <code>ScoreboardFile</code> records the following information about |
| 66 | the parent/daemon <code>proftpd</code> process: |
| 67 | <ul> |
| 68 | <li>scoreboard file format identifier |
| 69 | <li>daemon PID |
| 70 | <li>daemon uptime |
| 71 | <li>daemon version |
| 72 | </ul> |
| 73 | and for each session, the <code>ScoreboardFile</code> records: |
| 74 | <ul> |
| 75 | <li>session PID |
| 76 | <li>session protocol (<i>e.g.</i> "ftp", "ftps", "sftp") |
| 77 | <li>session UID |
| 78 | <li>session GID |
| 79 | <li>session user name |
| 80 | <li>session server IP address/port |
| 81 | <li>session virtual host name |
| 82 | <li>session client IP address, DNS name |
| 83 | <li>session <a href="Classes.html">class</a> |
| 84 | <li>time since session started |
| 85 | </ul> |
| 86 | and some other data related to data transfers. The data transfer-related fields |
| 87 | include the filename being transferred (may be relative or absolute, depending |
| 88 | on what the client sent), the transfer command (<i>e.g.</i> <code>RETR</code> |
| 89 | for downloads, <code>STOR</code> for uploads, <i>etc</i>), the amount of |
| 90 | data transferred so far, and percentage of transfer completed (for downloads |
| 91 | only). |
| 92 | |
| 93 | <p> |
| 94 | <b>Scrubbing the Scoreboard</b><br> |
| 95 | There is a bad habit among system administrators of using |
| 96 | <code>`kill -9'</code> to kill a misbehaving process. Any process that is |
| 97 | terminated this way, though, does not have a chance of properly shutting down. |
| 98 | Administrators would use <code>`kill -9'</code> on some of |
| 99 | <code>proftpd</code>'s session processes, which means that they would not be |
| 100 | able to remove their entries from the <code>ScoreboardFile</code>. |
| 101 | Utilities like <code>ftpwho</code> and <code>ftptop</code> would show sessions |
| 102 | that no longer existed. |
| 103 | |
| 104 | <p> |
| 105 | The chance of changing this bad habit in system administrators is slim, so |
| 106 | <code>proftpd</code> was changed to check the <code>ScoreboardFile</code> |
| 107 | periodically. It will scan the entire file, and for each scoreboard session |
| 108 | listed, it asks the operating system if that session process is still alive. |
| 109 | If the answer is no, the entry is removed from the file. This process is |
| 110 | known as "scrubbing". |
| 111 | |
| 112 | <p> |
| 113 | By default, this scrubbing process occurs every 30 seconds. For busy/heavily |
| 114 | loaded sites, this scrubbing interval might be too short; heavily loaded |
| 115 | servers are more likely to encounter lock contention issues between sessions |
| 116 | trying to update their scoreboard entry and the daemon trying to scrub |
| 117 | the scoreboard. Such sites are advised to use <code>ScoreboardScrub</code> |
| 118 | configuration directive. This directive can be used to turn on or off |
| 119 | the periodic scrubbing, or to set a different scrub interval. The following |
| 120 | shows some examples of <code>ScoreboardScrub</code> usage: |
| 121 | <pre> |
| 122 | # The default is to use scoreboard scrubbing, at the default interval |
| 123 | ScoreboardScrub on |
| 124 | |
| 125 | # If we are busy server, we might want to turn off scoreboard scrubbing |
| 126 | # entirely |
| 127 | ScoreboardScrub off |
| 128 | |
| 129 | # Scrubbing is acceptable, but have it happen every 5 minutes instead |
| 130 | ScoreboardScrub 300 |
| 131 | </pre> |
| 132 | |
| 133 | <p> |
| 134 | Note that if scoreboard scrubbing is turned off, the |
| 135 | <code>ScoreboardFile</code> can still be scrubbed on demand, either by using |
| 136 | the <a href="../contrib/mod_ctrls_admin.html#scoreboard"><code>mod_ctrls_admin</code></a>'s "ftpdctl scoreboard scrub" action, or by using the |
| 137 | <code>ftpscrub</code> command-line utility. |
| 138 | |
| 139 | <p> |
| 140 | <b>Frequently Asked Questions</b><br> |
| 141 | <font color=red>Question</font>: Why doesn't <code>proftpd</code> create the needed directories, if they're not there, when opening the scoreboard?<br> |
| 142 | <font color=blue>Answer</font>: The short answer is because that is the |
| 143 | job of the system administrator, not the application. The long reason |
| 144 | is that <code>proftpd</code> does not know the filesystem layout being |
| 145 | used, and does not know what sort of permissions should be given to any |
| 146 | directories it might need to create for its scoreboard. |
| 147 | |
| 148 | <p> |
| 149 | <font color=red>Question</font>: Can I copy my scoreboard from one server to another?<br> |
| 150 | <font color=blue>Answer</font>: No. <code>ScoreboardFile</code>s cannot be |
| 151 | copied from server to server; they are specific to that particular |
| 152 | installation. |
| 153 | |
| 154 | <p> |
| 155 | In the same fashion, you should not try to place the scoreboard on an NFS |
| 156 | filesystem. First, attempting to share the scoreboard is not supported, and |
| 157 | will only lead to trouble. Second, NFS does not support file locking, which |
| 158 | <code>proftpd</code> requires for handling the scoreboard. |
| 159 | |
| 160 | <p> |
| 161 | <font color=red>Question</font>: Why do I see "scrubbing scoreboard" in my debugging output?<br> |
| 162 | <font color=blue>Answer</font>: These debug messages indicate when the |
| 163 | <code>proftpd</code> daemon is scrubbing the <code>ScoreboardFile</code>. |
| 164 | |
| 165 | <p><a name="ScoreboardDisabling"> |
| 166 | <font color=red>Question</font>: Our site has <i>many</i> connections, and |
| 167 | it looks like the logins/sessions are slow. Analysis shows that the |
| 168 | session processes are all waiting/competing for the |
| 169 | <code>ScoreboardFile</code>. What can be done to fix this?<br> |
| 170 | <font color=blue>Answer</font>: One particular trick to use for this situation |
| 171 | is to use <code>/dev/null</code>, <i>e.g.</i>: |
| 172 | <pre> |
| 173 | ScoreboardFile /dev/null |
| 174 | </pre> |
| 175 | For one site which tried this configuration, <code>proftpd</code> was able |
| 176 | to function without complaining about using <code>/dev/null</code> as the |
| 177 | <code>ScoreboardFile</code>, the system load dropped dramatically, and |
| 178 | the FTP sessions were no longer slow. |
| 179 | |
| 180 | <p> |
| 181 | <b>However</b>, be aware that using this trick causes the following to |
| 182 | <b>NOT</b> work: |
| 183 | <ul> |
| 184 | <li>ftpcount |
| 185 | <li>ftpwho |
| 186 | <li>ftptop |
| 187 | <li>ftpdctl kick |
| 188 | <li><code>MaxClients</code> |
| 189 | <li><code>MaxClientsPerClass</code> |
| 190 | <li><code>MaxClientsPerHost</code> |
| 191 | <li><code>MaxClientsPerUser</code> |
| 192 | <li><code>MaxConnectionsPerHost</code> |
| 193 | <li><code>MaxHostsPerUser</code> |
| 194 | <li><code>MaxTransfersPerHost</code> |
| 195 | <li><code>MaxTransfersPerUser</code> |
| 196 | </ul> |
| 197 | |
| 198 | <p> |
| 199 | <font color=red>Question</font>: What should I do if I see this error in my |
| 200 | logs: |
| 201 | <pre> |
| 202 | error opening scoreboard: bad version (too old) |
| 203 | </pre> |
| 204 | <font color=blue>Answer</font>: This error usually only happens for servers |
| 205 | which have: |
| 206 | <pre> |
| 207 | ServerType inetd |
| 208 | </pre> |
| 209 | in their <code>proftpd.conf</code> files. It indicates that the existing |
| 210 | <code>ScoreboardFile</code> is using a format which is too old for the running |
| 211 | code. The fix is simple: delete that old <code>ScoreboardFile</code>. The |
| 212 | daemon will automatically create a new scoreboard in the correct format. |
| 213 | |
| 214 | <p> |
| 215 | <hr> |
| 216 | <font size=2><b><i> |
| 217 | © Copyright 2017 The ProFTPD Project<br> |
| 218 | All Rights Reserved<br> |
| 219 | </i></b></font> |
| 220 | <hr> |
| 221 | |
| 222 | </body> |
| 223 | </html> |