First I created 3 droplets on digital ocean with 4-cores and 8GB of RAM. Login as root to each and run:
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'| defmodule Ot.Mixfile do | |
| use Mix.Project | |
| def project do | |
| [app: :ot, | |
| version: "0.1.0", | |
| elixir: "~> 1.4", | |
| build_embedded: Mix.env == :prod, | |
| start_permanent: Mix.env == :prod, | |
| deps: deps()] |
| defmodule Hub do | |
| @moduledoc """ | |
| Publish/subscribe server. | |
| Subscription is done with a pattern. | |
| Example: | |
| {:ok, _pid} = Hub.start_link(name: :hub) | |
| Hub.subscribe(:hub, %{count: count} when count > 42) |
| require 'socket' | |
| class SuperSimpleService | |
| attr_reader :bind_address, :bind_port | |
| def initialize | |
| @bind_address = 'localhost' | |
| @bind_port = 12345 | |
| end |
| class Counter | |
| def initialize(initial_count = 0) | |
| @mailbox = Queue.new | |
| @replies = Queue.new | |
| @state = initial_count | |
| @server = process_messages | |
| end | |
| def increment | |
| mailbox.push([:handle_increment, 1]) |
| #!/usr/bin/env ruby | |
| ### | |
| # This utility adds missing parentheses to single word function calls | |
| # that are now treated as warnings on Elixir 1.4. | |
| # | |
| # Download this file on your project repo and execute | |
| # ruby ex14parens.rb --help | |
| #### | |
| require('fileutils') |
| module Animation exposing (..) | |
| import Task | |
| import Process | |
| import Time exposing (Time, millisecond) | |
| type Animation state | |
| = Setup state | |
| | Animate state |
| defmodule Config do | |
| @moduledoc """ | |
| This module handles fetching values from the config with some additional niceties | |
| """ | |
| @doc """ | |
| Fetches a value from the config, or from the environment if {:system, "VAR"} | |
| is provided. | |
| An optional default value can be provided if desired. |
Install makeself:
apt-get install makeself
or
brew install makeself
| # ATTENTION: This is now supported in plug_cowboy as of 2.1.0: | |
| # https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html | |
| defmodule DrainStop do | |
| @moduledoc """ | |
| DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown | |
| occurs. It first shuts down the acceptor, ensuring that no new requests can be | |
| made. It then waits for all pending requests to complete. If the timeout | |
| expires before this happens, it stops waiting, allowing the supervision tree | |
| to continue its shutdown order. |