Networking/Overview Notes

From MozillaWiki
Jump to: navigation, search

Request

  1. DNS prefetch
    • Possible improvement: pre-open connections to known TCP hosts for a given page
  2. The channel is opened using nsIChannel::AsyncOpen
  3. Proxy resolution
  4. Observer events (like http-on-modify-request)
    • May be used by add-ons
  5. Pre-open the TCP connection to the target "speculatively"
    • The number of connections to the same host is limited
      • Where the "host" is actually a combination of hostname, port and maybe other data
    • The total number of TCP connections made by Necko is also limited
    • There is a connection handling thread, notified by NSPR when data is available
  6. App Cache Lookup
    • This uses SQLite (Storage API)
  7. Disk or Memory Cache Lookup
  8. Actual request, with data dispatched as it becomes available
  9. OnStartRequest callback, after HTTP headers are received
  10. OnDataAvailable callback, data comes from NSPR via the socket I/O thread
  11. OnStopRequest, with error status code if required

Mentioned components

  • HTTP transaction object
  • Connection Manager
    • Finds persistent connections, or pre-started ones
    • Concurrency: we may start different connections during handshake
      • This may have limited performance in some cases, like single-threaded servers

Other notes

The max-connections preference controls how many connections are made, to avoid hitting limits of the underlying TCP layer in the operating system, which could cause the layer to stop responding in some cases.

  • 256 on Desktop
  • 64 on some Windows 32-bit variants
  • 32 on Desktop when using a proxy
  • 20 on Android (to avoid using too much memory for buffers)

Docs

Existing documentation that may be relevant: