hey guys :slightly_smiling_face: what’s the best p...
# help
f
hey guys 🙂 what’s the best practice for bigger projects. Do you recommend splitting the SST app into multiple smaller apps? Running
yarn start
takes a long time for us even if there are no changes. Is there a way to only debug stacks where you’re currently working on with
yarn start
and just have the rest of the stacks deployed or something like that?
t
Can you tell us more about what is happening during yarn start that is slowing things down?
Typically after first run, yarn start should have nothing to do
f
we have 8 stacks per domain (micro-service) and each stack has up to 4 sub stacks. Just iterating through all the stacks takes a long time. Executing
yarn start
without any changes takes more than 4 minutes.
t
wow that's crazy
Yeah it seems like you should have multiple sst apps at this point. I'm still curious to see why just compiling all the stacks into cdk takes so long
Another thing you could do is in your app ts file
you can conditionally initialize stacks
Copy code
if (app.local && process.env["SERVICE_I_AM_WORKING_ON"]) {
  // only initialize minimum needed stacks
}
Probably would have to be more sophisticated than that but the idea is you can control what spins up in your entry point
f
oh yeah, that’s a good idea too. haven’t thought about that
would you recommend splitting bigger projects in smaller sst apps anyways?
t
I'm always hesitant to split stuff up. Even for multiple stacks I wait until I really have to, same for services and same for apps
so I'd say avoid it for as long as you can
f
thanks for the help. I’ll try your approach
are there any good example sst projects about how to structure stacks and source code in a big project in production?
t
We don't have examples as big as yours, I put together this one which I think is a good pattern for a fairly large app: https://github.com/serverless-stack/serverless-stack/tree/master/examples/typescript-monorepo
f
thank you very much. I appreciate the help 🙂
f
Yeah agreed with @thdxr on not splitting up too early. @Fabian Ehringer can you run sst start once more without commenting out any stacks, and DM me your
.build/sst-debug.log
That will give us an idea on what’s taking long.
f
@Frank I sent you the
.build/sst-debug.log
file
I’m curious about how to split stacks later on. If I already know that my application will have “independent” and complex subdomains which can be seen as services, isn’t it better to split early on? A split like in the attached graphic will be difficult if the system’s already running in production, right? Or am I missing something?