Replies: 2 comments
-
netty-version: 4.17.2.final |
Beta Was this translation helpful? Give feedback.
0 replies
-
There is no such version. 4.1.72 maybe?
You need to provide a full reproducer first. Do you use epoll transport? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use netty to write a service similar to nginx, in which the static file adopts zero copy mode and uses http_ Load test and visit a very simple page. On the same machine, nginx QPS is 15000 +, while the service based on netty is only 3000 +. I feel that there is not much optimization space. Who knows why it is slow?
Core code of netty-static-file-sever:
WebRequest is wrapper from netty HttpRequest(decode by HttpRequestDecoder)
` private static void sendFile(Router router, WebRequest request, File file) {
ServerConf config = request.getServerConf();
HttpConnection session = request.getSession();
boolean keepAlive = request.keepAlive;
Channel client = session.getChannel();
try {
long size = file.length();
Calendar time = Calendar.getInstance();
long lastModified = file.lastModified();
DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, OK);
HttpHeaders headers = response.headers();
headers.set(HttpHeaderNames.SERVER,SERVER);
headers.set(HttpHeaderNames.DATE, DateFormatter.format(time.getTime()));
time.add(Calendar.SECOND, MeshConstants.HTTP_CACHE_SECONDS);
headers.set(HttpHeaderNames.EXPIRES, DateFormatter.format(time.getTime()));
headers.set(HttpHeaderNames.CACHE_CONTROL,CACHE_CONTROL_HEADER);
headers.set(HttpHeaderNames.LAST_MODIFIED, DateFormatter.format(new Date(lastModified)));
headers.set(HttpHeaderNames.CONNECTION, keepAlive ? HttpHeaderValues.KEEP_ALIVE : HttpHeaderValues.CLOSE);
String name = file.getName();
String extension = name.substring(name.lastIndexOf('.') + 1).toLowerCase();
MimeType mimeType = MimeTypes.INSTANCE.getByExtension(extension);
String mimeTypeStr = mimeType.getUtf8Type();
String charset = config.getCharset();
if (charset.charAt(0) != 'U' && !"UTF-8".equals(charset)) {
mimeTypeStr = (mimeType.getMimeType() + ";charset=" + charset);
}
content of test.html
<title>Welcome to Linux</title>`
Hello, Hunting Beagle!
`Machine(Linux 4.19.91-24.1.al7.x86_64):
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz
Stepping: 7
CPU MHz: 2499.998
BogoMIPS: 4999.99
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 1024K
L3 cache: 36608K
NUMA node0 CPU(s): 0-3
9 worker threads and 1 boss thread ,use NioEventLoop
test reuslt:
netty(http://127.0.0.1:1180):
./http_load -parallel 5 -fetches 3000 mesh.txt
3000 fetches, 5 max parallel, 546000 bytes, in 0.915385 seconds
182 mean bytes/connection
3277.31 fetches/sec, 596470 bytes/secmsecs/connect: 0.265005 mean, 3.444 max, 0.024 minmsecs/first-response: 1.06834 mean, 9.297 max, 0.093 minHTTP response codes:
code 200 -- 3000
nginx(http://127.0.0.1:8880):
./http_load -parallel 5 -fetches 3000 nginx.txt
3000 fetches, 5 max parallel, 546000 bytes, in 0.187201 seconds
182 mean bytes/connection
16025.6 fetches/sec, 2.91665e+06 bytes/sec
msecs/connect: 0.0896033 mean, 0.335 max, 0.027 min
msecs/first-response: 0.154147 mean, 0.503 max, 0.075 min
HTTP response codes:
code 200 -- 3000
Beta Was this translation helpful? Give feedback.
All reactions