Skip to content

Instantly share code, notes, and snippets.

View vongosling's full-sized avatar
🎯
Focusing

vongosling vongosling

🎯
Focusing
View GitHub Profile
@vongosling
vongosling / gist:9929680
Last active January 31, 2024 04:49
Performance Tuning

Three system configuration parameters must be set to support a large number of open files and TCP connections with large bursts of messages. Changes can be made using the /etc/rc.d/rc.local or /etc/sysctl.conf script to preserve changes after reboot.

1. /proc/sys/fs/file-max: The maximum number of concurrently open files.

fs.file-max = 1000000

2. /proc/sys/net/ipv4/tcp_max_syn_backlog: Maximum number of remembered connection requests, which are still did not receive an acknowledgment from connecting client. The default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines.

net.ipv4.tcp_max_syn_backlog = 3240000

3. /proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128.

net.core.somaxconn = 3240000

@vongosling
vongosling / gist:10353488
Created April 10, 2014 07:54
High performance Hessian Serialization and Derialization
package com.alibaba.mq.internal.tools;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;
import com.caucho.hessian.io.SerializerFactory;
@vongosling
vongosling / gist:11020739
Created April 18, 2014 01:45
Feeds system Result List based cursor theory
/**
* Result List based cursor theory
*
* @author vongosling
* @param <T>
*/
public class ResultCursorList<T> extends BaseDo {
private static final long serialVersionUID = -6593448580923210640L;
/**
@vongosling
vongosling / gist:8970351
Created February 13, 2014 05:44
Best practice - Httpclient 4.1
/**
* 史上最棒的HttpClient4封装,details please see
* http://hc.apache.org/httpcomponents-client-ga/tutorial/html/index.html
*
* @author von gosling 2013-5-7
*/
public class HttpClientManager {
//Consider ulimit
private static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 7500;
Love brevity and simplicity
@vongosling
vongosling / gist:9661145
Last active August 29, 2015 13:57
Performance analyzer v1.1.0
import java.io.IOException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
@vongosling
vongosling / gist:9461205
Created March 10, 2014 08:12
how-to-use-makefiles-in-your-web-projects
@vongosling
vongosling / gist:8970307
Last active August 29, 2015 13:56
Eclipse ADT FAQ:

Ubuntu 12.04.4,Kernel 3.5.0-45-generic

Problem 1:

Failed to start emulator: Cannot run program "/usr/bin/android-studio/sdk/tools/emulator": java.io.IOException: error=2

Solution:

sudo apt-get install libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5

Problem 2:

/android-4.4/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

Solution: