zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nrjdalal/silicon-virtualizer/master/install-qemu.sh)"
xcode-select --install
#!/usr/bin/env bash | |
export $(cat .env | xargs) | |
KINESIS_STREAM_SHARDS=${KINESIS_STREAM_SHARDS:-1} | |
export USE_SSL=true | |
awslocal kinesis create-stream --shard-count ${KINESIS_STREAM_SHARDS} \ | |
--stream-name ${KINESIS_STREAM_NAME} |
<?php | |
// curl -sS https://getcomposer.org/installer | php | |
// php composer.phar require aws/aws-sdk-php | |
// export AWS_ACCESS_KEY_ID=... | |
// export AWS_SECRET_ACCESS_KEY=... | |
$streamName = '<INSERT_YOUR_STREAMNAME_HERE>'; | |
$numberOfRecordsPerBatch = 10000; |
* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.
Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.
Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.
That's the theory, let's get to the work.
The API we are creating in this gist will follow these rules :
password
Grant Type only (no need for Authorization pages and such).v1.api.example.com
)The API will be written in PHP with the Symfony 3 framework. The following SF2 bundles are used :
#change it to latest version | |
NPS_VERSION=1.11.33.0; | |
echo "Changing Directory to $HOME..." | |
cd $HOME; | |
echo "Nginx version to install: " && \ | |
read NGINX_VERSION && \ | |
echo "Downloading nginx-$NGINX_VERSION..." && \ | |
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \ | |
echo "Installing Nginx Dependencies..." && \ |
For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.
Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon
with HyperThreading enabled, but it can work without problem on slower machines.
You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.
<?php | |
namespace App\Listeners; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; | |
use Symfony\Component\Security\Core\Exception\AuthenticationException; | |
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | |
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; |