# Accepting more HTTP requests simultaneously?

**URL:** <https://discourse.nodered.org/t/accepting-more-http-requests-simultaneously/67405>\
**Category:** General\
**Tags:** http-request\
**Created:** [6 September 2022 20:05 UTC](https://discourse.nodered.org/t/accepting-more-http-requests-simultaneously/67405 "2022-09-06T20:05:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [6 September 2022 20:05 UTC](https://discourse.nodered.org/t/accepting-more-http-requests-simultaneously/67405/1 "2022-09-06T20:05:56Z")

</div>

So i am using HTTP nodes to create an endpoint for a webhook for a particular service, which sends me data , that i format for influxdb, make a response to the original webhook (200 or error) and then i try to push the data to influxdb node.

Initially, this is a lot of data (around 100k requests in 1h) which all get to the flow (counted them), but the service of webhook returns a timeout for 60% of all messages (because it took longer than 30 seconds to send a response). The function nodes don't produce a single error.  
And the question is, how can I accept more HTTP requests simultaneously? There isn't any room for 'making better flow', I am running this on Digital Ocean as an App (docker image hosted) with the lowest tier.  
In settings.js and haven't noticed any configuration around this, so wanted to double-check, before upgrading my plan.  
Also, the endpoint is secured in settings.js via basic authentication(can this produce and lags)  
Few more things. All loops in functions have a break statement as soon as needed.  
Here is the image of the flow, and here is the function temperature\_event\_v4(all of them are initially the same):

```auto
var msg_inc = RED.util.cloneMessage(msg);

const event_obj = msg.payload.event
const label_obj = msg.payload.labels
var name = (event_obj.targetName).split('/')[3]
var label_name = 'targetName'
if (Object.keys(label_obj).length > 0) {
if (label_obj.name != "undefined") {
    if ((label_obj.name).length > 0) {
        name = (label_obj.name)
        label_name = 'name'
    }
}}
function check_for_samples() {
    if (typeof event_obj.data.temperature.samples == 'undefined'){ //CHANGE ME DEPENDING ON EVENT TYPE
        return false
    }
    if (event_obj.data.temperature.samples.length != 0 ){ //CHANGE ME 
        for (var i of event_obj.data.temperature.samples){ //CHANGE ME
            format_send_message(i.value,i.sampleTime) //CHANGE ME
        }
    }
    else {return false}
    return true;
}
function get_old_value(){
    format_send_message(event_obj.data.temperature.value,event_obj.data.temperature.updateTime) //CHANGE ME

}
function format_send_message(value,time) {
    msg= {
        measurement: "/DT/temp_sensor/" + name.replace(/\s/g, '_'), //CHANGE ME
    payload: [
        { value: value,
          time: new Date(time) },
        {event_type: "temperature", //CHANGE ME
        label_name: label_name,
        label_value: name
            }]
    }
    node.send([msg, null])
    return
}

if (check_for_samples() == false) {
    get_old_value()
    msg = {
        req: msg_inc.req,
        res: msg_inc.res
    }
    return [null, msg]
}

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/340bfa43f64a40fcf9dbef17c24e1ac053d92619.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [6 September 2022 20:13 UTC](https://discourse.nodered.org/t/accepting-more-http-requests-simultaneously/67405/2 "2022-09-06T20:13:54Z")

</div>

Best to ditch any security in node-red and move it to a reverse proxy which will perform a lot better. Let it do the auth and the tls termination.

After that, to improve performance you would probably need to scale horizontally which means creating multiple instances of node-red and use one or more proxies to handle load sharing - maybe as simply as round-robin routing.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 November 2022 20:14 UTC](https://discourse.nodered.org/t/accepting-more-http-requests-simultaneously/67405/3 "2022-11-05T20:14:05Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
