[RPC] Just an attemt to save some bandwidth #9893

pull CryptoManiac wants to merge 2 commits into bitcoin:master from CryptoManiac:rpc_gzip changing 7 files +193 −8
  1. CryptoManiac commented at 12:12 AM on March 1, 2017: none

    Simple gzip compression can be very useful when you're dealing with a lot of getblocktemplate or getrawmempool requests. It decreases GBT latency and allows you to save a lot of bandwidth.

    Just for example, I have few instances of bitcoind which are being used as template sources for eloipool. Each getblocktemplate response has a size of ~2MB. Being gzipped it shrinks down to ~800KB, which is a fairly reasonable size. :)

  2. Implement Gzip compression to save bandwidth 0011534a9a
  3. fanquake added the label RPC/REST/ZMQ on Mar 1, 2017
  4. jameshilliard commented at 12:27 AM on March 1, 2017: contributor

    @CryptoManiac why not just put a reverse proxy like nginx in front of the RPC interface?

  5. Use boost::iequals for better compatibility. 11ce86c4ac
  6. luke-jr commented at 12:40 AM on March 1, 2017: member

    You really shouldn't use RPC over a network...

  7. CryptoManiac commented at 12:40 AM on March 1, 2017: none

    @jameshilliard Well, this also may be a viable solution. Unfortunately, some people are limited to Windows operating system. To handle connections, the NT version of nginx is currently using only select(), so it's very slow. :(

  8. CryptoManiac commented at 12:48 AM on March 1, 2017: none

    @luke-jr Why not? If you have a walletless daemon, which listening at the private interface, then I'd say that nothing bad could happen.

    However, I understand the main idea. Closing for now.

  9. CryptoManiac closed this on Mar 1, 2017

  10. laanwj commented at 2:42 PM on March 3, 2017: member

    Just for example, I have few instances of bitcoind which are being used as template sources for eloipool. Each getblocktemplate response has a size of ~2MB. Being gzipped it shrinks down to ~800KB, which is a fairly reasonable size. :)

    This does increase the latency by bit, though, so on faster networks wouldn't want to use this.

    In any case I agree that this belongs externally. RPC is in the first place for local communication, for doing anything like compression, encryption put it behind a tunnel or nginx instance.

  11. CryptoManiac commented at 3:35 PM on March 3, 2017: none

    @laanwj It depends on your TCP/IP stack settings. In FreeBSD, for example, sometimes it's recommended to set net.inet.tcp.recvspace parameter to 8k. With such receive buffer size you can get a significant improvement even for a local instance of bitcoind, speed up looks like a linear function of compression ratio.

  12. jonasschnelli commented at 3:37 PM on March 3, 2017: contributor

    If you want compress data, why not reverse-proxy over apache and enable mod_deflate?

  13. CryptoManiac commented at 3:40 PM on March 3, 2017: none

    @jonasschnelli Because sometimes it doesn't help. Nginx needs to get the data from the upstream, so it can be affected by tcp/ip settings. Unfortunately, bitcoin doesn't support RPC over unix domain sockets for now.

  14. laanwj commented at 4:18 PM on March 3, 2017: member

    Unfortunately, bitcoin doesn't support RPC over unix domain sockets for now.

    Now that would be a welcome addition. But apparently it needs changes to evhttp. There's a similar ticket open for Transmission, which also uses evhttp.

  15. laanwj commented at 4:21 PM on March 3, 2017: member

    I just realized that it can be implemented with the current evhttp just fine - do the listening manually, set the socket to non-blocking, then pass the acceptfd to evhttp_accept_socket_with_handle, similarly as I did here for cloudabi: https://github.com/laanwj/bitcoin/blob/2017_03_cabi_fs/src/httpserver.cpp#L360.

  16. laanwj commented at 3:57 PM on March 4, 2017: member
  17. CryptoManiac commented at 2:59 PM on March 5, 2017: none

    @laanwj Nice one, thanks.

  18. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me