Skip to content

What service is suitable for my project

0

Hello,

I have many nodejs processes, doing the same task, spawned by one coordinator process that manages them.

They use prroxies to connect to the network, their task is to book some kind of appointments, each process hold information for one customer and try to login to the website, do preliminary verification and waits for appoitnments to be available and books one as fast as possible.

The challenge is that I would have about 100k process. They all use network (through a proxy) to communicate with the external website, and use local IPC channels to communicate with the main coordinator process to report their state and other information.

Each process will consume about 30mb. I susptected a problem on my local machine: the main nodejs process crashes after some time (I need to allow more memory for it) which makes the other processes quit. Another problem is the TCP ports range, which gets consumed very quickly. I think because of the proxy connections sockets. I mitigated this by limiting the number of sockets that are allowed to stay open, but with a higher number of processes I think I will get to the same issue again.

I am thinking of an EC instance that would be network optimized and capable of handling 100k tasks running in parallel without noticable delay in their work. But an EC instnace would face the proble of TCP port. The pros are facility of debugging and monitoring.

The other idea is to use Lambda functions, the problems I thought of: 1) where to put the coordinator server? then, how to communicate with it.. should I use HTTP? I would use more resources in this case... 2) what does Lambda functions use as processors or RAM? asre they optimized of speed, wouldn't a huge number of lambda functions running in the same time affect perforamance? what is the speed of network they use? It looks like a black box in terms of hardware and features.

2 Answers
2

Based on your project requirements and challenges, I would recommend using Amazon ECS (Elastic Container Service) with AWS Fargate as the most suitable service for your use case. Here's why:

  1. Scalability: ECS with Fargate can easily handle your requirement of running 100,000 processes in parallel. It allows you to run containers without managing the underlying infrastructure, which is ideal for your large-scale application.

  2. Networking: ECS provides advanced networking capabilities that can help address your TCP port range issues. It supports awsvpc network mode, which gives each task its own elastic network interface and private IP address, effectively solving the port exhaustion problem.

  3. Resource Management: With ECS, you can precisely define the CPU and memory requirements for each task. This allows you to allocate the 30MB of memory you mentioned for each process, and you can adjust the resources for your master process to prevent crashes.

  4. Inter-Process Communication: ECS tasks can communicate with each other and with external services. You can set up your master process as a separate service within the same ECS cluster, allowing for efficient communication between the master and worker processes.

  5. Monitoring and Debugging: ECS integrates well with AWS CloudWatch for monitoring and logging, providing you with the ability to debug and monitor your application effectively.

  6. Cost-Effective: Fargate allows you to pay only for the resources you use, which can be more cost-effective than running an EC2 instance, especially with fluctuating workloads.

  7. Network Performance: ECS with Fargate provides excellent network performance, which is crucial for your application that relies heavily on network communication.

While Lambda functions could potentially be used, they may not be ideal for your use case due to the need for long-running processes and the complexity of managing inter-process communication. ECS provides a more suitable environment for your application architecture, offering the right balance of scalability, performance, and manageability.
Sources
Amazon ECS Service Connect components - Amazon Elastic Container Service
Amazon API Gateway Features | API Management | Amazon Web Services

answered 2 years ago

EXPERT

reviewed 2 years ago

  • I documented a bit on ECS but I see that running a container for each process is not optimal because that would take resources to run the container image . these resrouces would be duplicated 100k times..

1

Given your requirements for network optimization and large-scale concurrent tasks, EC2 would be more suitable since it offers better control over the environment, no time limits, and direct management of network resources . Here's why EC2 is better for your case:

Resource Control

You can choose instances optimized for network (c5n.18xlarge or similar) Configure OS-level settings (ulimit, TCP parameters) Tune Node.js process settings directly

Cost Efficiency

Reserved instances for long-running processes No per-invocation costs like Lambda More predictable billing

Network Performance

Direct network interfaces Consistent latency Higher bandwidth Better proxy management

answered 2 years ago

  • what about the TCP port saturation issue? do you recommend running docker containers inside the instance in order to split the port high demand from the processes?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.