Skip to content

Instantly share code, notes, and snippets.

View vdel26's full-sized avatar

Victor Delgado vdel26

View GitHub Profile
# "Performance Scalability of a Multi-Core Web Server", Nov 2007
# Bryan Veal and Annie Foong, Intel Corporation, Page 4/10
fs.file-max = 5000000
net.core.netdev_max_backlog = 4096
net.core.optmem_max = 10000000
net.core.rmem_default = 10000000
net.core.rmem_max = 10000000
net.core.somaxconn = 4096
net.core.wmem_default = 10000000
net.core.wmem_max = 10000000

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI

Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

This is where any fun you might have been having ends. Now it’s time to get serious and talk about rules.

Writing CSS is hard. Even if you know all the intricacies of position and float and overflow and z-index, it’s easy to end up with spaghetti code where you need inline styles, !important rules, unused cruft, and general confusion. This guide provides some architecture for writing CSS so it stays clean and ma

@vdel26
vdel26 / apis.md
Last active November 20, 2018 16:44
APIs
@vdel26
vdel26 / nginx.conf
Last active August 29, 2015 14:14
Inject extra fields to API backend
upstream threescale_admin_api {
# 3scale adminstration API
server MYCOMPANY-admin.3scale.net:443 max_fails=5 fail_timeout=30;
}
location = /threescale_appfind {
internal;
set $provider_key "PROVIDERKEY";
proxy_pass "https://threescale_admin_api/admin/api/applications/find.xml?provider_key=$provider_key&app_id=$app_id";
@vdel26
vdel26 / applications_index.html
Created January 22, 2015 17:32
Filtering out deleted applications
<tbody>
{% for application in service.applications %}
{% unless application.plan.system_name == 'deleted' %}
<tr class="{% cycle 'applications': 'odd', 'even' %}" id="application_{{ application.id }}">
<td>
{{ application.name | link_to: application.url }}
</td>
{% if provider.multiple_services_allowed? %}
<td>{{ service.name }}</td>
{% endif %}
@vdel26
vdel26 / Editable-table.markdown
Last active August 29, 2015 14:13
Editable table
@vdel26
vdel26 / nginx-ip.conf
Last active February 26, 2021 18:57
Referrer filter detection in 3scale API proxy
# ENABLING REFERRER FILTERING IN NGINX – by IP address
# Using this snippet, 3scale will check if the origin of the API call
# matches the one introduce for that application by the developer
# Nginx will report to 3scale the origin IP address.
# replace the following location block in your nginx.conf file
location = /threescale_authrep {
internal;
set $provider_key "YOUR_PROVIDER_KEY";
@vdel26
vdel26 / index.html
Last active August 29, 2015 14:11
Update button workaround
<section>
<!-- BUTTON -->
<!-- add this where you would put the tag {{ 'Regenerate' | update_button: application.update_user_key_url }} -->
<form action="{{ application.update_user_key_url }}" class="button_to js-regenerateButton" method="post">
<div>
<input name="_method" type="hidden" value="put">
<input class="btn btn-danger btn-xs" type="submit" value="Regenerate">
</div>
</form>
<!-- ENDBUTTON -->
@vdel26
vdel26 / nginx.conf
Last active August 29, 2015 14:10
Send Application plan as a header named X-3scale-Plan
...
location / {
set $provider_key null;
set $cached_key null;
set $credentials null;
set $usage null;
set $service_id YOURSERVICEID;
set $proxy_pass null;
set $secret_token null;
set $plan_header null; # ADD THIS LINE