Skip to content

Instantly share code, notes, and snippets.

View bohrqiu's full-sized avatar

bohr bohrqiu

View GitHub Profile
@bohrqiu
bohrqiu / nginx-tuning.md
Created December 11, 2017 14:15 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

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.

@bohrqiu
bohrqiu / DataSourceHealthIndicator.java
Created November 5, 2015 07:47
DataSourceHealthIndicator with timeout
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bohrqiu
bohrqiu / .xml
Created August 18, 2015 10:18
build source to binary jar
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@bohrqiu
bohrqiu / gist:c8d8d19b9ed179d46390
Created July 17, 2015 10:11
spring async web
@RestController
public class AsyncController {
private static final Logger logger = LoggerFactory.getLogger(AsyncController.class);
private static AtomicInteger ai = new AtomicInteger();
@Autowired
private UserQueryService userQueryService;
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
@bohrqiu
bohrqiu / gist:40fdc0734f171eb5486e
Created September 23, 2014 16:50
查看java进程启动线程数
for pid in `ps -ef |grep java| grep -v 'grep'| awk '{print $2}'`
do
cat /proc/$pid/status |grep Threads | awk '{print $2}'
done
@bohrqiu
bohrqiu / gist:1f32d3575e89ec09e8d5
Last active August 29, 2015 14:05
maven remote debug
MAVEN_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8765'

transport

这里通常使用套接字传输。但是在 Windows 平台上也可以使用共享内存传输。

server

@bohrqiu
bohrqiu / monitor_create_thread
Last active August 29, 2015 14:05
btrace script monitor create new thread
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class TracingScript {
public static int count = 0;
@OnMethod(clazz = "java.lang.Thread", method = "start")
public static void onNewThread() {
@bohrqiu
bohrqiu / gist:817669f38261104c31d8
Created August 21, 2014 06:55
tomcat-maven-plugin config ssl
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>clean</id>
@bohrqiu
bohrqiu / Copier.java
Last active April 24, 2017 02:06
对象属性复制工具类,采用javassit生成源代码实现属性复制.并能实现包装类型和基础类型之间的转换
package bohr.javassist;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.CtNewMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.beans.BeanInfo;
@bohrqiu
bohrqiu / RequestBindingTest.java
Last active November 22, 2016 05:51
http request 转换为对象
import com.google.common.collect.Maps;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.core.convert.converter.Converter;