Skip to content

Conversation

@cubicdaiya
Copy link
Contributor

I added support for reverse proxing to unix socket. h2o's reverse proxing to unix socket is twice faster than its reverse proxing to tcp-port.

$ ab -k -n 10000 -c 500 "http://127.0.0.1:8081/tcp" 2>&1 | grep "Requests per second:"
Requests per second:    8923.78 [#/sec] (mean)
$ ab -k -n 10000 -c 500 "http://127.0.0.1:8081/unix" 2>&1 | grep "Requests per second:"
Requests per second:    16566.69 [#/sec] (mean)
$

The followings are configurations for this benchmark.

h2o.conf

listen:
  port: 8081
hosts:
  default:
    paths:
      /tcp:
        proxy.reverse.url: http://127.0.0.1/
      /unix:
        proxy.reverse.path: unix:/tmp/nginx.sock:/

nginx.conf

worker_processes 1; 

events {
    worker_connections 1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen 80;
        root   html;
    }

    server {
        listen unix:/tmp/nginx.sock;
        root   html;
    }

}

@kazuho
Copy link
Member

kazuho commented Nov 10, 2014

Thank you for the PR. IMO the proposed function is a must, and I am looking forward to merging the code into master. OTOH there is a massive refactor of lib/proxy.c going on in the kazuho/expr/proxy-keepalive branch, so I would first like to address things not related to the file at this moment and then decide how we should proceed.

So below are the suggestions / questions.

  • adding proto as an argument to h2o_socket_connect seems LGTM
    • please implement the libuv-side as well
  • the unix: URL parser
    • the function should be integrated into h2o_parse_url
    • and the callers of h2o_parse_url should validate the scheme
    • path of the unix socket should be returned as host
    • what is the syntax of the unix: scheme?
    • please write a brief document within the source code where the parsing logic is defined
    • using regex or something
    • for example, without any documentation it is unclear if : can be omitted or not
    • IMO : (and /) should be omittable, when path is /
    • please add tests to the test_parse_url function
    • they can be run by make test
  • please extend examples/socket-client.c to support unix sockets, so that it would be possible to test the functionality by using the example

@jodosha
Copy link

jodosha commented Jun 24, 2015

@kazuho Hello. Do you plan to merge this soon? Is there anything that I can do to help with this? Thank you.

@kazuho
Copy link
Member

kazuho commented Jun 29, 2015

@jodosha Thank you for the ping. The feature has just been merged to master in #383.

@kazuho kazuho closed this Jun 29, 2015
@jodosha
Copy link

jodosha commented Sep 14, 2015

@kazuho Thank you very much! 😍

gfx pushed a commit to gfx/h2o that referenced this pull request Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants