Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaos patterns? #24

Open
simontabor opened this issue Aug 14, 2020 · 0 comments
Open

Chaos patterns? #24

simontabor opened this issue Aug 14, 2020 · 0 comments

Comments

@simontabor
Copy link
Contributor

Chaos Squirrel is super flexible, but that means there's quite a lot of code involved to set up and use all the attacks (example below).

Should we define a pattern to help configuring all attacks?

We could also consider reducing the verbosity of { createAttack: Attack.configure... } - maybe some helper like Runner.weightedAttack(1, Attack.configure)

const Runner = require('@dazn/chaos-squirrel-runner');
const chaosMiddleware = require('@dazn/chaos-squirrel-runner-middy');
const os = require('os');

const CPUAttack = require('@dazn/chaos-squirrel-attack-cpu');
const BackgroundCPUAttack = require('@dazn/chaos-squirrel-attack-cpu-background');
const MemoryAttack = require('@dazn/chaos-squirrel-attack-memory');
const BackgroundMemoryAttack = require('@dazn/chaos-squirrel-attack-memory-background');
const OpenFilesAttack = require('@dazn/chaos-squirrel-attack-open-files');
const DiskSpaceAttack = require('@dazn/chaos-squirrel-attack-disk-space');

const createRunner = Runner.configure({
  probability: 1,
  possibleAttacks: [
    {
      createAttack: CPUAttack.configure({
        allowLoopEvery: 10,
      }),
    },
    {
      createAttack: BackgroundCPUAttack.configure({
        threads: os.cpus().length,
      }),
    },
    {
      createAttack: MemoryAttack.configure({
        size: 512000000, // lambda configured memory size
      }),
    },
    {
      createAttack: BackgroundMemoryAttack.configure({
        size: 512000000, // lambda configured memory size
      }),
    },
    {
      createAttack: OpenFilesAttack.configure({
        number: 1024, // lambda limit is 1024 open files
      }),
    },
    {
      createAttack: DiskSpaceAttack.configure({
        size: 512000000, // 512mb (lambda tmp storage size)
      }),
    },
  ],
});

module.exports = chaosMiddleware({ createRunner });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant