600-parallel-compute

command
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

600-parallel-compute

In this example, we distibute a Compute and Network-heavy workload to a Swarm cluster, by again, changing only a few lines of code from os/exec.

The program reads URLs from files.txt and starts containers in parallel to download and compute MD5 checksum of the file using wget -O- [url] | md5sum.

To run this example:

  1. Create a swarm cluster, edit its IP address and cert path in main.go.
  2. Set your env vars to point to Swarm master:
  3. Run:
$ docker pull busybox
$ go run main.go
os/exec vs dexec
Mode Execution Time Bytes Downloaded
Locally on a single node (os/exec) 1m20s 0.8 GB
5-node Docker Swarm Cluster (dexec) on cloud 10s 396 bytes
Migration from os/exec

Good ol’ 5-lines:

> 	cl, _ := docker.NewClientFromEnv()
> 	d = dexec.Docker{cl}
> 	m, _ := dexec.ByCreatingContainer(docker.CreateContainerOptions{
> 		Config: &docker.Config{Image: "busybox"}})
< 	cmd := exec.Command("sh", "-c", fmt.Sprintf("wget -qO- %s | md5sum", url))
> 	cmd := d.Command(m, "sh", "-c", fmt.Sprintf("wget -qO- %s | md5sum", url))

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL