Problem with using AWS lambda without API gateway

I am using EMQX with a plugin emqx_auth_http that deployed in AWS lambda.

It works properly when EMQX connects to AWS lambda via AWS API gateway. However, I would like EMQX connect directly to lambda to save API gateway cost

After changing it 1-2 hours, I got lots of error about ‘server_unavailable’ and there is no invocation in authenticate function in AWS lambda. How could I solve this issue?

According to my experience, the performance of AWS Lambda, or the TPS it allows is a big bottleneck, what is your peak TPS and average TPS? And did you have any problems when you used it before?

Thank you for asking & support.

Based on metrics that I got before the problem happened, the max TPS is 600 while the average TPS is 350.

At that time, I can see lot of errors. Here below is an example.

[info] 3a7f4940-b3f1-4a3c-927a-faca27c89318@ file: emqx_connection.erl, line: 550, mfa: {emqx_connection,terminate,2}, msg: terminate, pid: <0.12995.1131>, reason: {shutdown,server_unavailable}

After checking logs carefully, I found that there is the same problem before but it happened once or twice a day.

It works fine after restarting EMQX but it happens again after 1-2 hours.

Besides this Info log, are there any other error logs? There should be an error log that will indicate a more specific reason for the failure.

And what version of EMQX are you using?

I am using EMQX v4.4.8.

For error, I saw this error log a lot.

2022-11-10T06:32:52.426502+00:00 [error] 22457322-16f0-4dd2-b0fc-11e3cd930ea0@ [Auth http] Request auth path: /sg-prd/mqtt/authenticate, error: timeout

It seems that the authentication request timed out caused by the insufficient performance of AWS Lambda.

The problem is the system was back to normal again around 2 hours after restarting EMQX so I think it may not relate to permission.

Have you tested the performance of AWS Lambda?

I will do load test and let you know again. Thank you.