Skip to content
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

Phoenix and Plug benchmark improvs #32

Merged
merged 5 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ all: elixir node ruby crystal go rust swift client benchmarker
elixir: plug phoenix

plug:
cd elixir/plug; mix deps.get --force
cd elixir/plug; mix deps.get --force; MIX_ENV=prod mix release --no-tar
ln -s -f ../elixir/plug/bin/server_elixir_plug bin/.

phoenix:
cd elixir/phoenix; mix deps.get --force
cd elixir/phoenix; mix deps.get --force; MIX_ENV=prod mix release --no-tar
ln -s -f ../elixir/phoenix/bin/server_elixir_phoenix bin/.

# --- node.js ---
Expand Down
9 changes: 6 additions & 3 deletions benchmarker/src/benchmarker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ class ExecServer
kill_proc("puma")
elsif @target.name == "express"
kill_proc("node")
elsif @target.name == "plug" ||
@target.name == "phoenix"
kill_proc("iex")
elsif @target.name == "plug"
path = File.expand_path("../../../elixir/plug/_build/prod/rel/my_plug/bin/my_plug", __FILE__)
Process.run("bash #{path} stop", shell: true)
elsif @target.name == "phoenix"
path = File.expand_path("../../../elixir/phoenix/_build/prod/rel/my_phoenix/bin/my_phoenix", __FILE__)
Process.run("bash #{path} stop", shell: true)
end
end

Expand Down
2 changes: 1 addition & 1 deletion elixir/phoenix/bin/server_elixir_phoenix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cd elixir/phoenix; mix phoenix.server
cd elixir/phoenix; _build/prod/rel/my_phoenix/bin/my_phoenix foreground
9 changes: 1 addition & 8 deletions elixir/phoenix/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
# is restricted to this project.
use Mix.Config

# General application configuration
config :my_phoenix,
ecto_repos: [MyPhoenix.Repo]

# Configures the endpoint
config :my_phoenix, MyPhoenix.Endpoint,
url: [host: "localhost"],
secret_key_base: "eJQGBAkhoqat49OeguToy3eM72UD6JYb0rsS6koTzrLzl37AapXPW2Uqffa2yc8W",
render_errors: [view: MyPhoenix.ErrorView, accepts: ~w(json)],
pubsub: [name: MyPhoenix.PubSub,
adapter: Phoenix.PubSub.PG2]
secret_key_base: "eJQGBAkhoqat49OeguToy3eM72UD6JYb0rsS6koTzrLzl37AapXPW2Uqffa2yc8W"

# Configures Elixir's Logger
config :logger, :console,
Expand Down
12 changes: 2 additions & 10 deletions elixir/phoenix/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ use Mix.Config
#
# You should also configure the url host to something
# meaningful, we use this information when generating URLs.
#
# Finally, we also include the path to a manifest
# containing the digested version of static files. This
# manifest is generated by the mix phoenix.digest task
# which you typically run after static files are built.
config :my_phoenix, MyPhoenix.Endpoint,
http: [port: {:system, "PORT"}],
http: [port: 3000, protocol_options: [max_keepalive: 5_000_000]],
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/manifest.json"
server: true

# Do not print debug messages in production
config :logger, level: :info
Expand Down Expand Up @@ -56,6 +51,3 @@ config :logger, level: :info
# config :my_phoenix, MyPhoenix.Endpoint, server: true
#

# Finally import the config/prod.secret.exs
# which should be versioned separately.
import_config "prod.secret.exs"
37 changes: 0 additions & 37 deletions elixir/phoenix/lib/my_phoenix/endpoint.ex
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
defmodule MyPhoenix.Endpoint do
use Phoenix.Endpoint, otp_app: :my_phoenix

socket "/socket", MyPhoenix.UserSocket

# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug Plug.Static,
at: "/", from: :my_phoenix, gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)

plug Plug.RequestId
plug Plug.Logger

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end

plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison

plug Plug.MethodOverride
plug Plug.Head

# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
# plug Plug.Session,
# store: :cookie,
# key: "_my_phoenix_key",
# signing_salt: "EvOisfLx"

plug MyPhoenix.Router
end
6 changes: 3 additions & 3 deletions elixir/phoenix/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule MyPhoenix.Mixfile do
# Type `mix help compile.app` for more information.
def application do
[mod: {MyPhoenix, []},
applications: [:phoenix, :phoenix_pubsub, :cowboy, :logger, :gettext]]
applications: [:phoenix, :cowboy, :logger, :gettext]]
end

# Specifies which paths to compile per environment.
Expand All @@ -29,8 +29,8 @@ defmodule MyPhoenix.Mixfile do
# Type `mix help deps` for examples and options.
defp deps do
[{:phoenix, "~> 1.2.1"},
{:phoenix_pubsub, "~> 1.0"},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"}]
{:cowboy, "~> 1.0"},
{:distillery, "~> 1.0"}]
end
end
1 change: 1 addition & 0 deletions elixir/phoenix/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"},
"db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"decimal": {:hex, :decimal, "1.3.1", "157b3cedb2bfcb5359372a7766dd7a41091ad34578296e951f58a946fcab49c6", [:mix], [], "hexpm"},
"distillery": {:hex, :distillery, "1.3.5", "d13d3a5282c8e7b2128383e9b4491dac39dc9ab37b43fc000f10e687057cfacd", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "2.1.4", "d1ba932813ec0e0d9db481ef2c17777f1cefb11fc90fa7c142ff354972dfba7e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm"},
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], [], "hexpm"},
Expand Down
93 changes: 0 additions & 93 deletions elixir/phoenix/priv/gettext/en/LC_MESSAGES/errors.po

This file was deleted.

91 changes: 0 additions & 91 deletions elixir/phoenix/priv/gettext/errors.pot

This file was deleted.

47 changes: 47 additions & 0 deletions elixir/phoenix/rel/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,
# This sets the default release built by `mix release`
default_release: :default,
# This sets the default environment used by `mix release`
default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/configuration.html


# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
set dev_mode: true
set include_erts: false
set cookie: :"p&HC>s]l6tm&2eA},g&p.<@,G0l>?U](12&o}jE=PBI5}yIxuZ$21hFhZD^MYm;n"
end

environment :prod do
set include_erts: true
set include_src: false
set cookie: :"PgB>l@G;J5onFgVAIx:nCN5Pk_fe/{|p{R@OBn0V!Td0rf4f12vN^ba6n06F75dZ"
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :my_phoenix do
set version: current_version(:my_phoenix)
set applications: [
:runtime_tools
]
end

8 changes: 0 additions & 8 deletions elixir/phoenix/test/controllers/page_controller_test.exs

This file was deleted.

Loading