Skip to content

Instantly share code, notes, and snippets.

View donghaic's full-sized avatar

dhai donghaic

  • Bejing
View GitHub Profile
@donghaic
donghaic / nginx-tuning.md
Created February 21, 2023 06:34 — 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.

git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@donghaic
donghaic / clickhouse-err.txt
Last active July 13, 2020 04:01
clickhouse query err
Code: 241. DB::Exception: Received from localhost:9000. DB::Exception: Memory limit (for query) exceeded: would use 9.32 GiB (attempt to allocate chunk of 4320768 bytes), maximum: 9.31 GiB: (while reading column total_video_click): (while reading from part /data/clickhouse-db/data/data/ssp/app_report_raw_local_v2/20200712_82666_83775_5/ from mark 12079 with max_rows_to_read = 8192)
set config for the query works
set max_bytes_before_external_group_by=10000000000;
set max_memory_usage=20000000000;
set distributed_aggregation_memory_efficient=1;
package com.van;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
>
<head>
<meta charset="UTF-8"/>
<title>upload file</title>
<link type="text/css" th:href="@{bootstrap.min.css}" rel="stylesheet"/>
<link type="text/css" th:href="@{webuploader.css}" rel="stylesheet"/>
</head>
public void testupload1() throws IOException {
JSONObject ret_msg = init();
String upload_id = ret_msg.getString("upload_id");
int byteBlockSize = ret_msg.getInteger("length");
Path path = Paths.get("D:\\tmp\\mextest.mp4");
long length = path.toFile().length();
int noOfBlocks = (int) Math.ceil((double) length / (double) byteBlockSize);
FileChannel binaryFileChannel = new RandomAccessFile(path.toFile(), "r").getChannel();
int start = 0;
long left = length;