Douvi
I created an API to check if my server is alive, after checking the log I saw my reply take >= 100s from the server but on my computer, it takes about 8ms… Can someone tell me why?
Log
14:06:29.154 request_id=XXX [info] GET /api/heartbeat
14:06:29.154 request_id=XXX [info] Sent 200 in 306s
14:06:34.155 request_id=XXX [info] GET /api/heartbeat
14:06:34.155 request_id=XXX [info] Sent 200 in 86s
14:06:39.153 request_id=XXX [info] GET /api/heartbeat
14:06:39.153 request_id=XXX [info] Sent 200 in 112s
API
def api_heartbeat(conn, _params) do
send_resp(conn, :ok, "")
end
Route
pipeline :api do
plug :accepts, ["json"]
end
scope "/api", PhoenixTWeb do
pipe_through :api
get "/heartbeat", PageController, :api_heartbeat
end
mix.exs
defmodule PhoenixT.MixProject do
use Mix.Project
def project do
[
app: :phoenix_t,
version: "1.1.0",
elixir: "1.8.2",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
deps: deps(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test]
]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[
mod: {PhoenixT.Application, []},
extra_applications: [:logger, :runtime_tools, :peerage]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.4.6"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:excoveralls, "~> 0.10", only: :test},
{:distillery, "~> 2.0", override: true},
{:peerage, "~> 1.0"},
]
end
end
conf.exs
use Mix.Config
# Configures the endpoint
config :phoenix_t, PhoenixTWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "secret_key_base",
render_errors: [view: PhoenixTWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: PhoenixT.PubSub, adapter: Phoenix.PubSub.PG2]
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
prod.exs
config :phoenix_t, PhoenixTWeb.Endpoint,
http: [:inet6, port: "${PORT}"],
url: [host: "${HOST}", port: "${PORT}"], # This is critical for ensuring web-sockets properly authorize.
cache_static_manifest: "priv/static/cache_manifest.json",
server: true,
secret_key_base: "secret_key_base",
root: ".",
# TODO - Need to remove the ligne below
check_origin: false,
version: Application.spec(:phoenix_t, :vsn)
# Do not print debug messages in production
config :logger, level: :info
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
This looks like a terminal output problem, mine displays as
Sent 200 in 92µs. Your terminal is probably having trouble displaying theµDouvi
good point, what about the big gap from 86µs - 300µs ?
benwilson512
Mix lazy loads code. The first request always takes longer since it needs to get the code loaded. After that your 86microseconds and 112 microseconds are all pretty close. Keep in mind we’re talking about a difference of 20 millionths of a second.