teleren/devto huggingface dataset:
Configuring PHP-FPM For High Network Traffic
Tags: php, nginx, phpfpm, network
Published: 2018-01-23 19:50:14

---
title: "Configuring PHP-FPM For High Network Traffic"
published: true
description: 
tags: PHP, Nginx, PHP-FPM, network
---
![php-fpm logo](https://thepracticaldev.s3.amazonaws.com/i/gp15idn6v674qdh0ob98.png)

Maintaining a constant response time on a server with high network traffic while using PHP is probably the hardest & most annoying thing I've done in my career. Switching from Apache to Nginx was a huge performance upgrade... that lasted for a solid half hour before the RPS (requests-per-second) was causing the stack to overflow once again.

I started browsing Stack Overflow & Google (devs best & worst friend/enemy) for answers, I found a few posts that showed how to fix the issue (PHP-FPM conf) but didn't explain anything. As a hands-on developer, I wanted to know how things worked. 

Originally my PHP-FPM conf looked something like this
```
[www]

user = apache
group = apache

listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1

pm = dynamic

pm.max_children = 200

pm.start_servers = 20

pm.min_spare_servers = 10
pm.max_spare_servers = 20

pm.max_requests = 1000
```

I started reading into what `pm = dynamic` meant and I found this (in another conf file haha)

> dynamic - the number of child processes are set dynamically based on the following directives. With this process management, there will be always at least 1 children.

Hold on... are all 200 children being spawned on startup? Are they always idle?

Yes & Yes (i think). I started viewing and recording memory usage of the `apache` pool using `ps aux |grep apache`. No matter how many requests were being processed (0 requests - 1000 requests) there were always 200 children alive. Don't get me wrong, I love kids but 200 at once for no reason is a bit much.

After spending a few hours screwing with my PHP-FPM conf and running stress tests I came up with this
```
[www]

user = apache
group = apache

listen = 127.0.0.1:9001

listen.allowed_clients = 127.0.0.1

pm = ondemand
pm.max_children = 200
pm.process_idle_timeout = 1s
pm.max_requests = 1000
```

I ran another stress test: 2000 RPS (requests-per-second) for one min and the average response time went from 1000MS to 120MS.

What happened?

PHP-FPM's PM (Pool Manager) was spawning 200 children on startup, even though those children were idle the PM was using unnecessary resources to manage the children. The switch from `dynamic` to `ondemand` allowed children to be spawned when needed and killed them after 1s of inactivity. 

Feel free to critique this post, I have little knowledge of how PHP-FPM's pool manager works. I felt that it might be helpful to someone in a bind with PHP-FPM.

EDIT: Some info in this article is incorrect e.g I confused `dynamic` with `static` spawning 200 children on startup. However, I still use this same setup on new servers and it performs so much better than any other config I've used.
What does "-R min" flag means in my test script in package.json?
Tags: quickquestion, testing, node, help
Published: 2018-01-23 22:52:12

---
title: What does "-R min" flag means in my test script in package.json?
published: true
description: Solved
tags: quickquestion, testing, node, help
---

Hello all. I can't find the answer on google and on the docs. I don't want to post in Stackoverflow either. Any ideas what the `-R min` flag means?

```javascript
  "scripts": {
    "test": "nodemon --exec \"mocha -R min\"",
    "start": "nodemon app.js"
  },

```

Thanks!

~~EDIT: Okay, I figured out the `min` flag. It supressed verbose test messages.~~

~~Without min flag: `√ it should GET all the users (78ms)`
With min flag: `1 passing (156ms)`~~

~~How about -R?~~

EDIT #2: Okay, the `-R` flag and `min` argument are supposed to go together. As @weswedding said, it's the Reporter flag and the next word is the name of the reporter. In this case, `min`.

~~And of course, it's all in the docs....~~
入門自然言語処理 pp.83-86
Tags: nlp, python, reading
Published: 2018-01-23 22:22:47

---
title: 入門自然言語処理 pp.83-86
published: true
description: 
tags: nlp, python, reading
---

ウェブのテキストを取得する方法。nltk 3.2.5 では、サンプルがそのまま動かない。3.1.2章のHTML処理をするには、以下のようにする。

```
$ pip install beautifulsoup4
```

```
$ python
Python 3.6.3 (default, Dec 14 2017, 14:27:23)
...
>>> import nltk
>>> from bs4 import BeautifulSoup
>>> url = "http://news.bbc.co.uk/2/hi/health/2284783.stm"
>>> html = urlopen(url).read()
>>> html = html.decode()
>>> soup = BeautifulSoup(html, "html.parser")
>>> raw = soup.get_text()
>>> tokens = nltk.word_tokenize(raw)
>>> text = nltk.Text(tokens)
>>> text.concordance("gene")
Displaying 7 of 7 matches:
hey say too few people now carry the gene for blondes to last beyond the next
blonde hair is caused by a recessive gene . In order for a child to have blond
...
```
Explain CSS BEM Structures Like I'm Five
Tags: explainlikeimfive
Published: 2018-01-23 21:20:01

---
title: Explain CSS BEM Structures Like I'm Five
published: true
tags: explainlikeimfive
---

I)   What are they?
II)  How and why are they used?
III) What are some recommend resources for further learning?

Cheers,
Dave
Simple layouts with Flexbox in React
Tags: react, flexbox, simple, layout
Published: 2018-01-23 20:47:05

---
title: Simple layouts with Flexbox in React
published: true
description: Making layouts with Flexbox in React, very simple
tags: react,flexbox,simple,layout
---

Every time I have to do an UI, the most tedious task I face is align elements inside a div, either vertically or horizontally.

However, since I got to know Flexbox, all this has changed, aligning elements became a very easy task.

If you don't know about Flexbox, I suggest you read this guide, it's very clear: [https://css-tricks.com/snippets/css/a-guide-to-flexbox/](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)

I work with React, so, nothing is easier than having a couple of components (`Row` and `Column`) that can be used as follow:
```
import { Column, Row } from 'simple-flexbox';
...
<Column flexGrow={1}>
    <Row horizontal='center'>
        <h1>HEADER</h1>
    </Row>
    <Row vertical='center'>
        <Column flexGrow={1} horizontal='center'>
            <h3> Column 1 </h3>
            <span> column 1 content </span>
        </Column>
        <Column flexGrow={1} horizontal='center'>
            <h3> Column 2 </h3>
            <span> column 2 content </span>
        </Column>
    </Row>
</Column>
```

And get the next result:
![result](https://thepracticaldev.s3.amazonaws.com/i/gqnvmrqnwnlagfxkp9vl.PNG)

See a live example here: [https://codesandbox.io/s/rwyl6zyp0p?module=%2FExample.js](https://codesandbox.io/s/rwyl6zyp0p?module=%2FExample.js)

A header, two columns, all the content is centered, and no CSS lines. I've tried to keep it as simple as possible.
However, you have access to all the advanced features of Flexbox, and you can even send your own styles to `Row` and `Column`, ie:
```
<Row
    flexGrow={1}
    flexBasis='auto'
    horizontal='space-between'
    style={{ backgroundColor: 'blue' }}
>
```

This module named [simple-flexbox](https://www.npmjs.com/package/simple-flexbox) is published in [npm](https://www.npmjs.com/package/simple-flexbox), and you can see its code and documentation here:
[https://github.com/llorentegerman/simple-flexbox](https://github.com/llorentegerman/simple-flexbox)

In the following link there are several advanced examples, which I will update periodically:
[https://codesandbox.io/s/z3p04l3vol](https://codesandbox.io/s/z3p04l3vol)

I hope you find them useful
Explain DHCP Like I'm Five
Tags: explainlikeimfive
Published: 2018-01-23 20:31:53

---
title: Explain DHCP Like I'm Five
published: true
tags: explainlikeimfive
---

I've been having trouble with a little RPI Kubernetes cluster on my school's network, and I think the issue has to do with DHCP. Problem is, I don't really understand a whole lot of networking stuff, let alone DHCP. Could anyone ELI5?

**EDIT**: ~~Thanks to the help of the campus "networking guy," I believe we've fixed the issue. Apparently wired interfaces get shut off after a while if they aren't "chatty." While my cluster is chatty by virtue of being a cluster, since it's all on the same ethernet switch, that doesn't really matter. While an actual fix would be to investigate interface shutdowns on non-chattiness, the temporary fix? Curl google.com every minute!~~ https://twitter.com/dvdmuckle/status/958019950001745922 Full Twitter thread of the issue solution! Turns out it wasn't exactly DHCP!
Welcome Thread - v8
Tags: welcome
Published: 2018-01-23 19:34:41

---
title: Welcome Thread - v8
published: true
description: Introduce yourself to the community!
tags: welcome
---

![Lisa and Bart Simpson saying hi](https://media.giphy.com/media/xT5LMNWIOq8E1JJ3b2/giphy.gif)

# Welcome!
1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋

Let's go!
Why use immutability?
Tags: immutability, discuss
Published: 2018-01-23 18:57:16

---
title: Why use immutability?
published: true
description: Why and how do you use Immutability
tags: immutability, discuss
---

Hey all,

Why do you use immutabile objects, and states? What real benefits does it offer in your situation? Is there any feasible alternative that you could’ve implemented, if so what was it and why was it feasible?
How to Authenticate Firebase and Angular with Auth0: Part 1 - Custom Tokens & Lazy Loading
Tags: firebase, angular, javascript, node
Published: 2018-01-23 18:46:34

---
title: "How to Authenticate Firebase and Angular with Auth0: Part 1 - Custom Tokens & Lazy Loading"
published: true
description: Learn how to authenticate a real-time Firebase and Angular app with an API using Auth0 with custom Firebase tokens.
tags: #firebase #angular #javascript #nodejs
canonical_url: https://auth0.com/blog/how-to-authenticate-firebase-and-angular-with-auth0-part-1/
---
Learn how to authenticate a real-time Firebase and Angular app with an API using Auth0 with custom Firebase tokens. In the first part of this tutorial, we will set up Angular with scalable, real-world architecture with lazy loading and implement Auth0 authentication on the client and server

[Read on 🔥🅰️](https://auth0.com/blog/how-to-authenticate-firebase-and-angular-with-auth0-part-1/?utm_source=dev&utm_medium=sc&utm_campaign=firebase_angular)

![How to Authenticate Firebase and Angular with Auth0](https://thepracticaldev.s3.amazonaws.com/i/58odat1wvlxqa00po99g.png)
Rudy Breaking News!
Tags: beginners, productivity, testing
Published: 2018-01-23 18:43:40

---
title: Rudy Breaking News!
published: true
description: The update of Rudy we were talking about.
tags: #beginner, #productivity, #testing
---

This post is a follow-up on the [first post about Rudy](https://dev.to/rftlexists/test-44p8).

So Rudy kind of recognized, that he is going into a depression streak again, and he decided to break the bad patterns by creating a new good one.

After conducting some research he decided that the best weapon out there for him, with the current circumstances, is establishing a [morning routine](https://dev.to/_patrickgod/the-miracle-of-a-morning-routine-1eho).

Here's what he wrote so far:

__07:30           : Wake up__
__07:33 - 07:50   : Shower__
__07:50 - 08:20   : Drink + Food__
__08:20 - 09:00   : Free time *__
__09:00           : Go to Work__ 

And he didn't want to be so _restrictive_ with himself, so he wrote an array of choices to select based on the mood. 

___* Free time___ : 

* Study ([Computer Science Distilled](https://www.goodreads.com/book/show/34189798-computer-science-distilled))
* Start Thesis
 * Start by the subject
* Free writing
* Medidate
* Masturbate
* Watch a movie
* Play a video game

___But during free time don't sleep.___

> If you can't go all the way, go at least a bit closer to get a cleaner view.
Using IOT (Internet of Things) for Remote Education
Published: 2018-01-23 18:01:32

---
title: Using IOT (Internet of Things) for Remote Education
published: true
description: A proposal on how embedded devices and IOT techniques can be used to provide education to distant and remote locations.
tags: 
---
https://www.dropbox.com/s/odz0mflxuvpnu27/REMOTE%20LEARNING%20AND%20EDUCATION%20WITH%20IOT.pdf?dl=0
Announcing Sustaining Memberships for dev.to
Tags: meta
Published: 2018-01-23 16:35:41

---
title: Announcing Sustaining Memberships for dev.to
published: true
description: Your support will help us continue our mission of cultivating a community that is kind, open, and interesting.
tags: meta
cover_image: https://thepracticaldev.s3.amazonaws.com/i/wpj6kk6l9y7us4j0c7o3.png
---

Today we are launching [DEV Sustaining Memberships](/membership). Backing us in this way will help support the growth of our kind, open, creative community of amazingly talented software developers.

As described in our [2018 outlook](https://dev.to/ben/what-to-expect-from-devto-in-2018-22ia), this is a **_pay-what-you-can_** membership with tiered rewards. For as little as a dollar, you can become a sustaining member and unlock a few exclusive features.  The tiers go up from there, and include more and more benefits — including exclusive stickers!

![DEV SHOP](https://thepracticaldev.s3.amazonaws.com/i/4royu8rhpa13wtzs5zvm.png)

The [membership landing page](/membership) goes into detail on the rewards for each tier, so let me take a moment to elaborate on one very important benefit.

## Workshops

Members paying $25 a month are going to have the opportunity to take part in regular online software development workshops. These workshops will be interactive ways of building your skills and keeping up with the important and constantly-evolving areas of our craft.

We will be announcing workshop details as they are finalized, but let me tell you about one we have lined up: **My workshop on web performance**. This is an area of our field I have devoted a lot of my career studying. I'm very excited to impart some of my learnings to members from the community in a format that does better justice to the subject than than blog posts and conference talks.

While talks and blog posts are an important part of the developer ecosystem, workshops have shaped some of the most critical experiences for me in growing as a developer. We have confirmed this to be the case for many others and the industry experts we expect to take part in teaching is really exciting.  We intend to specialize in this medium in an online environment as much as we can.


_If you are most interested in the workshop tier but are unable afford the $25/mo, we are offering scholarships. You can fill out an application [here](https://dev.to/p/scholarships)._

## Thank you for being awesome

Sooo many [dev.to](/) members have been with us from the beginning, and I promise that we are doing everything we can to build out the platform to be ten times better than it currently is. A huge part of that is having a sustainable business model so that we can invest in improvements.


### [Pick the Sustaining Membership level that is right for you.](/membership)

As per the 2018 outlook, we have a couple more initiatives to launch soon and we are well on track with all of them. Thank you so much for being a part of the community.
Hash (In)equality
Tags: ruby, testing
Published: 2018-01-23 12:58:20

---
title: Hash (In)equality
published: true
description: Explicating hash differences
tags: ruby, testing
---

In my automated testing, I often want to test a pair of hashes for equality.  If the pair is equal, well enough.

But if they're not equal, the simple way to record that is to log the failure, along with the two hashes.  If the hashes are very small:  I can visually compare them to determine the differences.

But for larger hashes, I can't easily determine the differences visually.  That's where my class <code>HashHelpler</code> comes in.

It has method <code>HashHelper.compare(expected, actual)</code> that accepts the expected and actual hashes, and returns a hash having four keys and their corresponding values:

<ul>
	<li><code>:ok</code>:  value is a hash containing the key/value pairs that are in both <code>expected</code> and <code>actual</code>.</li>
	<li><code>:missing</code>:  value is a hash containing the key/value pairs that are in <code>expected</code>, but not in <code>actual</code>.</li>
	<li><code>:unexpected</code>:  value is a hash containing the key/value pairs that are in <code>actual</code>, but not in <code>expected</code>.</li>
	<li><code>:changed</code>:  value is a hash detailing the keys that are in both <code>expected</code> and <code>actual</code>, but whose values differ.</li>
</ul>

So:  in my method <code>Log#verdict_assert_equal?</code>, a failed hash comparison gets and logs the detailed differences, making it easy to see what's what.

Links:

<ul>
	<li>Class <a href="https://github.com/BurdetteLamar/RubyTest/blob/master/lib/helpers/hash_helper.rb">HashHelper</a>.</li>
	<li>Class <a href="https://github.com/BurdetteLamar/RubyTest/blob/master/test/helpers/hash_helper_test.rb">HashHelperTest</a>.  (We're all testers here, right?).</li>
	<li>Module <a href="https://github.com/BurdetteLamar/RubyTest/blob/master/lib/log/verdict_assertion.rb">VerdictAssertion</a>.  See method <code>_verdict_equal?</code></li>
</ul>
2017-2018 - What I learned and what I plan to learn
Tags: career
Published: 2018-01-23 08:25:13

---
title: 2017-2018 - What I learned and what I plan to learn
published: true
description: Here are some of the things that I learned this 2017 and the things I want to learn this 2018!
tags: meta,career
---

*Please read the original article for more information: https://medium.com/@jepedesu/2017-2018-6a70e2940a49*

2017 was amazing! There were a lot of things that I learned. But I'm not going to stop there. There are still sooooo much I don't know -- even things that I don't know that I don't know them! This year I'm going to set sail into the depths of the coding universe and learn what I can.

Here are some of the things that I learned this 2017 and the things I want to learn this 2018!

## Things I learned in 2017
1. Getting into Open Source
2. Functional Programming
3. Artificial Intelligence
4. GraphQL
5. React and React Native
6. Containers
7. Website Optimization and Progressive Web Apps
8. Getting into the tech community

## Things I want to learn in 2018
1. ElasticSearch
2. Blockchain
3. More Computer Science
4. State Machines
5. Web Components
6. Reactive Programming
7. Serverless
8. Electronics and Internet of Things
9. Building iOS apps with Swift
10. Mixed Reality
11. Data Science
12. Bleeding Edge AI
13. Nature-based Algorithms
14. A bunch of Programming Languages
Sparrowform - Sparrowdo Provision for Terraform Backed Instances
Tags: terraform, sparrowdo, perl6, devops
Published: 2018-01-23 07:55:03

---
title: Sparrowform - Sparrowdo Provision for Terraform Backed Instances 
published: true
description: How to provision Terraform based infrastructure by Sparrowdo/Sparrowform  
tags: Terraform, Sparrowdo, Perl6, devops
---


# Meet Sparrowform

[![asciicast](https://asciinema.org/a/158919.png)](https://asciinema.org/a/158919)

[Sparrowform](https://github.com/melezhik/sparrowform) is a tool to provision Terraform instances by running [Sparrowdo](https://github.com/melezhik/sparrowdo) scenarios. You bootstrap infrastructure by Terraform script and then let Sparrowdo to adjust instances by running configuration tasks against. Here is simple plan how to do this:


# Bootstrap infrastructure with Terraform

Say, we have tree aws ec2 instances with corresponding Terraform resources names - `example1`, `example2` and `example3`. We create instances by a related Terraform scenario `bootstrap.tf`:

```
$ nano bootstrap.tf
$ terraform apply
``` 

# Create some Sparrowdo scenarios:

Now, as we get three ec2 instances up and running, we want to apply some desired configuration to all of them, let's create three Sparrowdo scenarios, one per each instance to describe desired configuration. We should name scenarios files as `$terraform-resource-type.$resource-name.sparrowfile`. 

For simplicity, all we want is to install Nginx server on every ec2 instance, the scenario would be trivial:
 

```
$ nano aws_instance.example1.sparrowfile

#!perl6
package-install "nginx";
service-enable "nginx";
service-start "nginx";

$ nano aws_instance.example1.sparrowfile # so on, for other two instances 

```


# Run provision by Sparrowform/Sparrowdo

Now, as we are ready with our Sparrowdo scenarios, let's run them on our freshly Terraform backed instances. We add `--ssh_private_key`, `--ssh_user` parameters to Sparrowform launcher so that Sparrowdo knows how to connect to the instances by ssh:


```
$ sparrowform --bootstrap --ssh_private_key=~/.ssh/aws.pub --ssh_user=ec2-user
```


# What else?


Look at [Sparrowform](https://github.com/melezhik/sparrowform) to know more. Last nifty example to make you animated:


```
# We can avoid creating Sparrowdo scenarios, using Sparrowdo modules as 
# This one liner.
# Let's install Nginx server on all instances:
$ zef install Sparrowdo::Nginx
$ sparrowform --ssh_private_key=~/.ssh/aws.pub --ssh_user=ec2-user --module_run=Nginx
```
Sick Picks: Podcasts
Tags: podcast
Published: 2018-01-23 05:13:58

---
title: "Sick Picks: Podcasts"
published: true
description: Start 2018 listening to software development podcasts!
tags: podcast, 
---

*[Original posted on my blog](https://leonardofaria.net/2018/01/23/sick-picks-podcasts/)*

I am huge fan of podcasts. It is always nice to hear people's thoughts, struggles, jokes and sick picks. Here is my short list of development-related podcasts.

*   **[Syntax](https://syntax.fm/)**: Wes Bos and Scott Tolinski talk about webdevelopment. You can expect lots of Javascript - especially React - and CSS here.
*   **[Developer Tea](https://spec.fm/podcasts/developer-tea)**: plenty of episodes about the developer career. Off the top of my head I would recommend the episode about [Experienced Developers and Impostor Syndrome](https://spec.fm/podcasts/developer-tea/32884).
*   **[Front End Happy Hour](http://frontendhappyhour.com/)**: each episode the hosts toast when someone says a specific word. If you are into style guides, you must head [their episode about it](http://frontendhappyhour.com/episodes/top-shelf-style-guides/).
*   **[Software Engineering Radio](http://www.se-radio.net/)**: I didn't hear a lot of episodes here but it caught my eyes ears [the one with David Heinemeier Hansson](http://www.se-radio.net/2016/06/se-radio-episode-261-david-heinemeier-hansson-on-the-state-of-rails-monoliths-and-more/), creator of Ruby on Rails.
*   **[Vancouver Tech Podcast](http://www.vancouvertechpodcast.ca/)**: last but not least, I've been living in Vancouver for more than 2 years and it's nice to hear the local tech scene.

What are your favourite podcasts? Let me know in the comments :)