acrolink
Running Phoenix on a Unix socket
Any experiences and performance results compared to running the Phoenix server on a TCP port? Any minimum system requirements to use Unix socket?
Marked As Solved
acrolink
Indeed, it is possible like this:
http: [ip: {:local, '/srv/phx/project/development.socket'}, port: 0],
Also Liked
cjbottaro
For posterity, this works…
{:ok, pid} = Plug.Adapters.Cowboy.http(MyPlug, [], ip: {:local, "my_plug.sock"}, port: 0)
The port: 0 is important; it won’t work without it.
Also, you gotta rm my_plug.sock when you’re done otherwise it won’t start up again: :eaddrinuse (address already in use)
voltone
With :gen_tcp you can use the tuple {:local, path} to connect to a unix socket. It is mentioned in the :inet module docs:
If you want to make HTTP requests to a unix socket you can use HTTPoison/Hackney with the “http+unix://” scheme, which is a bit of a hidden feature:
https://github.com/benoitc/hackney/blob/master/src/hackney_url.erl#L45
mbuhot
Turns out the new file system in OTP 21 fixed the issue, so Phoenix should now run over a unix socket.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









