New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for reverse proxing to unix socket #51

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@cubicdaiya
Contributor

cubicdaiya commented Nov 9, 2014

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

This comment has been minimized.

Show comment
Hide comment
@kazuho

kazuho Nov 10, 2014

Member

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
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

This comment has been minimized.

Show comment
Hide comment
@jodosha

jodosha 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.

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

This comment has been minimized.

Show comment
Hide comment
@kazuho

kazuho Jun 29, 2015

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@jodosha

jodosha Sep 14, 2015

@kazuho Thank you very much! 😍

jodosha commented Sep 14, 2015

@kazuho Thank you very much! 😍

deweerdt added a commit to deweerdt/h2o that referenced this pull request Feb 20, 2017

Merge pull request h2o#51 from fastly/deweerdt/add-a-hint-mode-for-co…
…mpression

Add a HINT mode for compression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment