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 / 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 / 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;
@bohrqiu
bohrqiu / cxf_client_timeout_config
Last active January 1, 2016 23:19
cxf client timeout configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd"
@bohrqiu
bohrqiu / maven-package-verson
Last active December 31, 2015 19:58
maven打包时,自动生成静态资源版本号
1.在web项目pom里面添加build插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<includes>
@bohrqiu
bohrqiu / jetty
Last active December 31, 2015 19:49
java web项目测试时启动jetty
1.在项目父pom中添加build插件:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.0.v20131115</version>
<configuration>
<reload>automatic</reload>
</configuration>
</plugin>
@bohrqiu
bohrqiu / dump.sh
Last active December 22, 2015 19:19
java进程关闭时收集dump
JAVA_HOME=/usr/lib/jvm/java-7-sun
OUTPUT_HOME=/var/log/webapps/cs/
DEPLOY_HOME=/usr/local/apache-tomcat-7.0.26-cs
HOST_NAME=`hostname`
DUMP_PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_HOME" |awk '{print $2}'`
if [ -z "$DUMP_PIDS" ]; then
echo "The server $HOST_NAME is not started!"
exit 1;
fi
@bohrqiu
bohrqiu / gist:5503811
Created May 2, 2013 17:24
druid slf4j日志集成
diff --git a/src/main/java/com/alibaba/druid/support/logging/LogFactory.java b/src/main/java/com/alibaba/druid/support/logging/LogFactory.java
index dbdc21a..fe6f467 100644
--- a/src/main/java/com/alibaba/druid/support/logging/LogFactory.java
+++ b/src/main/java/com/alibaba/druid/support/logging/LogFactory.java
@@ -23,9 +23,7 @@
private static Constructor logConstructor;
static {
- // TODO add slf4j logging
-
@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