-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: first off, how to test the tls feature of gnet? #1
Comments
Line 42 in 584e828
Here is test code |
i did
is this repo correct? i would like to test it this way as main.go file,
(chatgpt4 suggested) possible to make a https version for testing? else a tcp echo version will do fine too
|
where are you come from? I understand Chinese. If you prefer, I can communicate with you in Chinese. |
In the next few days, I will use your example to see if I can send and receive data packets over HTTPS. |
@kolinfluence
and the console output the expected results you should execute git pull https://github.com/leslie-fei/gnet.git, then modify the go.mod file by replacing 'gnet' with the local path like this
|
@leslie-fei is there anything wrong the soreuseport option when using tls? previous working versions from |
OK, I try it later |
@leslie-fei i think dont waste time try it, it uses old gnet and seemed the tls here also cannot use reuse port option if you can get it to work and know why, do "fix" it if it's not going to take more than 30 mins. |
@leslie-fei can you save the main.go file in gnet/example folder (or somewhere else) and run the main file? this works on browser but i'm getting these information, not sure if it's my cert / key issue. not sure and i cant confirm. so can you make the example folder that works with a self signed cert / key?
|
@leslie-fei it works with wget https://127.0.0.1:443/ --no-check-certificate and it doesnt work with wrk -d 30 -c 100 https://127.0.0.1:443/ u can try and see what i mean |
pls send me the link where i can buy u coffees for making this work on browser. thx |
When I open the browser, it's fine to ignore certificate authentication. There should be an issue with wrk as well, probably not ignoring certificate validation. Do you have WeChat? Can I communicate with you through WeChat? |
@kolinfluence If you can add me on WeChat, my username is linfeipengwx. |
@leslie-fei ok, will add u.
and if you use wrk,
wrk -c 100000 -d 30 http://127.0.0.1:443/
|
It looks like there is an issue, I need time to fix it. |
You can update the latest code, I have tested that REUSEPORT works.
REUSE and WRK |
@leslie-fei there's still some problem... wrk gets stuck sometimes. GOMAXPROCS=1 ./main it gets stuck sometimes. pls try a few times and see
without GOMAXPROCS, sometimes it works, sometimes doesnt.
|
@kolinfluence
|
@leslie-fei maybe u changed something i didnt update.
|
@kolinfluence https://github.com/leslie-fei/gnet-example my test code git repository |
@leslie-fei tried, didnt work, wrk can stuck sometimes, the more you run, the performance drops greatly and wrk still does 0 i try on another laptop and revert.. hang on |
@leslie-fei on my other laptop, how to resolve?
|
@kolinfluence you can update the latest code, https://github.com/leslie-fei/gnet-example |
@leslie-fei i tried. can you do GOMAXPROCS=1 ./main & and try with wrk -t 3 -d 10 https://127.0.0.1:443/ ? try running wrk a few times using the same parameter |
|
@leslie-fei my wrk works on the top performing frameworks u can imagine including rust / c / vlang / golang / cpp etc basically i use the wrk extremely frequently. hope u can make it work in this version too.
|
I don't think it's an issue with wrk, as the version is 4.1.0. |
@leslie-fei i dunno what's wrong but i'm using amd ryzen ubuntu 22.04 lscpu
|
Could you try curling it to see if it returns the result 'HELLO WORLD' correctly? Could you share the console output after you run the main function?
|
@leslie-fei i changed it to 8443 so i can run it as a normal user. previous version i ran as root. this latest 7a55 version i ran as 8443. it works sometimes, sometimes dont. i check again.
curl -k https://127.0.0.1:8443 also main uses 1200% cpu. all of it |
@kolinfluence Please pull the latest code, kill the existing process, recompile main.go. I suspect there might be an issue with the infinite loop condition in the handshake. I just added a critical condition. Try it again after starting. First test whether cURL can pass through, and then stress test with wrk if possible. |
@leslie-fei first few times of curl show no error, after running a few more curl... 7 or > 8... previously 2nd run of curl will stuck, now 2nd time works
wrk will show a lot more these errors.
conclusion : i confirm with you everything works now except that the error message is shown. wrk shows plenty times complete without error. no errors on wrk side. only errors on server side
you are very close to solving the issue now, wrk error:
|
@kolinfluence I will fix it tomorrow |
@leslie-fei by the way, it is working toooo fast. the overhead of tls is like nothing. that's extremely impressive (or totally wrong?) what i mean is, non tls is 165,000 req/s, the older-other tls version, 90,000 req/s. the one u have is 158,000 req/s. that's very amazing. i hope it is truly so too. NEW EDIT : i thought about it for some time, i think it "feels" like all the tls goes through only once? coz this is really too fast. does not seem to make sense. let's see how u fix the "error" first. i guesstimate the best result should be 105k - 120k req/s. p.s. : thank you for trusting my results. sometimes people think i'm trying to be funny or did the test wrong :D p.p.s. : i rarely use wechat. pls add me my username kolinfluence. asking u to add me coz i dunno how to add u |
@kolinfluence Please pull the latest code and try compiling and running it again. I've already added you on WeChat. What chat application do you usually use? I can also sign up for one. |
@kolinfluence If you suspect that TLS might not be effective, you can replace it with a secure certificate. Then update your host domain pointing to your own machine and try accessing it via HTTPS using a browser. I have tested locally that browsers can access HTTPS and verify certificates. |
@leslie-fei wrk issues, i changed to port 8443 (just fyi) latest test with latest main.go wrk -d 10000 -c 1000 https://127.0.0.1:8443/
|
@leslie-fei
this is not fine with errors above
|
@leslie-fei this has errors generated on server side when used with GOMAXPROCS=1, the whole wrk completes without errors with 150k req/s wrk -d 10 -c 10 https://127.0.0.1:8443/ |
@leslie-fei final test for this, conclusion when ran without errors, it's doing 87k tls req/s per core. (as expected) BUT when specifying gomaxprocs parameters will definitely show this error, then the req/s is not accurate
|
@kolinfluence please pull latest code build and run again, I may have found the issue. I hope for success. What chat application do you usually use? I can also sign up for one. |
@leslie-fei so far, so good. u are amazing. it works perfect now. no issues i can find. it's doing 150k req/s https, that's kind of crazy because non tls does 165k req/s. i'm running longer duration multiple connection tests on it with different gomaxprocs settings. will revert with findings. everything seems to be running ok for 30s durations, 100 connections etc. it seems fine. let me do 5 minutes segments and revert on findings. thx! |
@leslie-fei it is working perfectly fine. can you share what u did and mention how u fixed it? just curious |
@kolinfluence Because gnet is event-driven based on epoll, I need to change all data reading operations in std TLS to non-blocking. Previously, there was a dead loop issue when the handshake was completed and there were still data in InBoundBuffer. I just made changes here, you can check the commit log in https://github.com/leslie-fei/gnettls. |
@leslie-fei i confirm there's no issue with https testing. Do u have something for tls tcp echo testing? u can ask for pull request now and review. but i hope to see how u'll implement a tcp tls echo server as an example use. p.s. : i read the code, it's fantastic. great work. everything works. ask for pull request |
@kolinfluence Are you looking to implement an HTTPS server, or do you just need to add TLS functionality to TCP? If it's HTTPS, you'll also have to handle encoding and decoding HTTP packets, which can be cumbersome. Does your use case require such high performance that the Go standard library cannot meet? |
@leslie-fei yes, i need both https and tcp tls. can you do an example for tcp tls? i can write my own but im curious how u'll implement it. maybe u can provide the basic example for me to test on too. and yes, i've stretched the limit with other high performance libraries too. just fyi i've used all the other frameworks in golang u can think of. |
@leslie-fei before u scold me for suggesting h2, pls check out the older version of gnet that has it working do take some time to see if it can be implemented easily using what has already been done. thx! |
@kolinfluence I will try to see if it's feasible, but since I'm also working regularly, I won't be able to handle it promptly. I can spare some time to create a simplest TCP TLS echo example for you first. |
@leslie-fei , yes, pls delete the image thx. can i ask what is this goroutine pool used for in the context of this http server? how to use it? do we need to use it?
using the pool while the server is idle generates 2 heap objects per second. so i was wondering if it's truly necessary, req/s wise, it is slower too when used. how would u use it by the way? |
@leslie-fei tls tcp echo server by chatgpt, advisable to use this way?
|
@kolinfluence Change the repository address from https://github.com/leslie-fei/gnettls.git to https://github.com/leslie-fei/gnet-tls.git, pull the code, navigate to example/echo, run go build main.go and then execute ./main. It implements a relatively simple TLS TCP echo server & client, where the server uses gnet TLS and the client uses the standard library's TLS TCP client. You should also transfer the issue to the repository gnet-tls.
|
|
@kolinfluence I don't think panjf will merge this TLS change anytime soon; after all, it's quite a large amount of code that introduces the entire std TLS and might lack sufficient testing. From what I saw in your issue, supporting HTTP protocol encoding and decoding also requires some time. |
@leslie-fei erm... so basically, do u think you can do the protocol support or something? because it works without the tls... i mean i dont really understand why http protocol encoding / decoding will affect this tls that's all. is it difficult or will it be long? i thought it's just simple reuse of existing... when can it be supported? really hope to use it asap. can i sponsor u some coffees to speed this up? u'll help me greatly. |
@kolinfluence I've been researching it recently, as I still need to work, I'll look into it in my spare time. Can you receive messages on Telegram? |
@leslie-fei yes i see ur msg on telegram now. do mention when the protocol can be done and if i can assist too. thx |
Actions I've taken before I'm here
Questions with details
as titled
Code snippets (optional)
No response
The text was updated successfully, but these errors were encountered: