# When I run a ray-cpp(v-2.31.0) project,I find the task just in the local node, it don't spred

**URL:** <https://discuss.ray.io/t/when-i-run-a-ray-cpp-v-2-31-0-project-i-find-the-task-just-in-the-local-node-it-dont-spred/23072>\
**Category:** Uncategorized\
**Created:** [September 5, 2025, 6:41am UTC](https://discuss.ray.io/t/when-i-run-a-ray-cpp-v-2-31-0-project-i-find-the-task-just-in-the-local-node-it-dont-spred/23072 "2025-09-05T06:41:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![youwu699](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/youwu699/32/8212_2.png) [@youwu699](https://discuss.ray.io/u/youwu699)\
**Post date:** [September 5, 2025, 6:41am UTC](https://discuss.ray.io/t/when-i-run-a-ray-cpp-v-2-31-0-project-i-find-the-task-just-in-the-local-node-it-dont-spred/23072/1 "2025-09-05T06:41:40Z")

</div>

```cpp
#include <ray/api.h>
#include <iostream>
#include <unistd.h>
#include <vector>
#include <unordered_map>
#include <thread>
#include <chrono>

double integrate(double start, double end) {
    char hostname[256];
    gethostname(hostname, sizeof(hostname));
    pid_t pid = getpid();
 

  
    std::this_thread::sleep_for(std::chrono::seconds(3));

   
    double sum = 0.0;
    const long long steps = 10000000;
    double step = (end - start) / steps;
    for (long long i = 0; i < steps; ++i) {
        double x = start + i * step;
        sum += std::sin(x) * std::cos(x);
    }

  
    return sum * step;
}

RAY_REMOTE(integrate);

int main() {
    try {
      
        ray::RayConfig config;
        const char* ray_address = std::getenv("RAY_ADDRESS");
        if (ray_address) {
            config.address = ray_address;
        } else {
            config.address = "192.168.0.103:6379";
        }
        
        std::cout << "===== connect to Ray: " << config.address << " =====" << std::endl;
        ray::Init(config);
        std::cout << "===== Ray connect success =====" << std::endl;

      
        std::vector<ray::ObjectRef<double>> results;
        std::cout << "\n===== sub task =====" << std::endl;
        for (int i = 0; i < 100; ++i) {
            double start = i * 10000.0;
            double end = (i + 1) * 10000.0;
         
            auto task = ray::Task(integrate).Remote(start, end);
            results.push_back(task);
           
        }

      
        std::cout << "\n===== wait =====" << std::endl;
        std::vector<double> task_results;
        for (auto& ref : results) {
         
            std::shared_ptr<double> result_ptr = ray::Get(ref);
            task_results.push_back(*result_ptr); 
        }

    
        double total = 0.0;
        for (int i = 0; i < task_results.size(); i++) {
            total += task_results[i];
          
        }
        std::cout << "\n===== resulet =====" << std::endl;
        std::cout << "sum: " << total << std::endl;

        ray::Shutdown();
        return 0;

    } catch (const std::exception& e) {
        std::cerr << "\n===== error =====" << std::endl;
        std::cerr << "error message: " << e.what() << std::endl;
        ray::Shutdown();
        return 1;
    }
}
// the code 

```

 ![sk](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/5/5aec2c2f146e65cada303ed3a717406e394d83fe.jpeg)

I have three machine but only the .104 server get the task

---

<div class="post-metadata">

**Author:** ![youwu699](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/youwu699/32/8212_2.png) [@youwu699](https://discuss.ray.io/u/youwu699)\
**Post date:** [September 5, 2025, 6:45am UTC](https://discuss.ray.io/t/when-i-run-a-ray-cpp-v-2-31-0-project-i-find-the-task-just-in-the-local-node-it-dont-spred/23072/2 "2025-09-05T06:45:39Z")

</div>

the other server at ⬇  
head\_node

 ![QQ_1757054621663](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/3/368f927832a8cdc0c091c7c184d1954f3aec4dd3.jpeg)
