Comments (9)
@rohitjoshi I've just had a closer look and I don't think that error is trigger by the balancer_by_lua*
config snippet you provided.
The error message is generated in your cosocket related Lua code when you try continuing using a cosocket object after a fatal error has happened in a previous cosocket operation. How to fix:
- ensure you have Lua code that checks the return values of all the cosocket operations that may fail and handle any errors properly in your own Lua code (like retry or give up).
- after you have handled all the errors on the Lua land, turn off such automatic cosocket error logging by adding the following line to your
nginx.conf
:
lua_socket_log_errors off;
from lua-resty-core.
@rohitjoshi Will you please provide a minimal and standalone example that we can easily reproduce the issue on our side?
from lua-resty-core.
@rohitjoshi BTW, it's a bad idea to parse a JSON string in your balancer_by_lua*
handler upon every request. It's very expensive.
from lua-resty-core.
@rohitjoshi For the minimal example that can reproduce the issue, I don't think you need the JSON part or the branching code testing the size of the server array (you can just use a static table, or even a static host and port pair).
from lua-resty-core.
@rohitjoshi And for the standalone part of the example, you need to provide your location
definition, as well as a fake backend server in the same nginx.conf
, as well as the test requests required to access the entry point of your nginx server.
from lua-resty-core.
@rohitjoshi Please see the test suite for balancer_by_lua*
and ngx.balancer
for an idea of what standalone and minimal examples look like:
https://github.com/openresty/lua-resty-core/blob/master/t/balancer.t
from lua-resty-core.
@rohitjoshi A fatal error in a cosocket operation closes the underlying socket immediately. So when you go ahead and try sending data on this closed socket without re-connecting, you get the error log message "attempt to send data on a closed socket" from the cosocket object when your do not turn off lua_socket_log_errors
(default on
).
from lua-resty-core.
@agentzh thanks. Yes, errors seem to be due to upstream simulator server closing the connection. I did not see errors reflected in my client (wrk).
I ran performance test using two scenarios using wrk.
./wrk -c15000 -t128 -d30s -H "Api-Key: rohit" "https://10.205.192.64:11111/perftest_category/success?http_status=201&body_size=100"
Based on the body_size
query parameter, simulator server returns that size in the response.
I ran 3 tests with body size 100, 500 and 1000.
- Balancer by Lua:
Response size: 100 Requests/sec: 69123.15 Avg Latency: 239.27ms
Response size: 500 Requests/sec: 68385.40 Avg Latency: 247.50ms
Response size: 1000 Requests/sec: 64240.14 Avg Latency: 254.42ms
- Nginx upstream with nginx-upstream-dynamic-servers module (dynamic resolve)
Response size: 100 Requests/sec: 71613.66 Avg Latency: 248.93ms
Response size: 500 Requests/sec: 68367.540 Avg Latency: 251.14ms
Response size: 1000 Requests/sec: 65553.37 Avg Latency: 242.05ms
Both test are returning almost identical results with nginx upstream has slightly lower latency and higher throughput. May be due to my code where I am converting string to table using msgpack. (I replaced json with msgpack). Will optimize this.
By the way, I did not see any attempt to send data on a closed socket
while using nginx upstream but did see upstream prematurely closed connection while reading response header from upstream
errors which might be equivalent to what is logged when balancer by lua is used.
Thanks again.
from lua-resty-core.
Setting lua_socket_log_errors
does disable these errors.
from lua-resty-core.
Related Issues (20)
- can ngx.resty.core support proxy ceritificate setting directives
- ngx.var.ssl_ciphers in ssl_certificate_by_lua HOT 1
- Failed on IBM Z/S390x HOT 1
- how to set error log level ? HOT 4
- 2022/06/14 05:43:28 [error] 159#0: *45 lua entry thread aborted: runtime error: /opt/nginx/lib/lua/resty/core/misc.lua:178: /usr/local/lib/libluajit-5.1.so.2: undefined symbol: ngx_http_lua_ffi_req_is_internal stack traceback: coroutine 0: [C]: in function '__index' /opt/nginx/lib/lua/resty/core/misc.lua:178: in function 'is_internal' /opt/nginx/scripts/manage_access_session.lua:70: in main chunk, client: 10.221.16.1 HOT 11
- no ssl session caching happen, always new session ID!
- 0.1.24 tag missing features from lua-nginx-module 0.10.22
- I want to get all the extension information of client hello, not just server name , what can I do? HOT 6
- b64.encode_base64url problem HOT 3
- undocumented that errlog.set_filter_level can not be set lower than error_log level HOT 1
- ngx.sleep() does not work in ssl_client_hello_by_lua* HOT 13
- undefined symbol: ngx_http_lua_ffi_var_get HOT 3
- ngx.balancer 如何设置重试状态码 HOT 3
- why the lua version number is commented out in Makefile HOT 4
- nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found: HOT 5
- ngx.shared.DICT:ttl() returns 0 for the exipred key
- Requesting information about security fixes. HOT 1
- runtime error: /usr/local/openresty/lualib/ngx/semaphore.lua:129: attempt to perform arithmetic on a nil value HOT 1
- get_client_hello_ext() | lua-resty-core/lib/ngx/ssl | Issue with custom TLS Extension Type 17516
- The feature set_upstream_tls is marked as being introduced in version 0.1.29
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-resty-core.