reactioncommerce / reaction-cli

A command line tool for working with Reaction Commerce.
33 stars 20 forks source link

clear blocking response on CLI #46

Closed aaronjudd closed 6 years ago

aaronjudd commented 7 years ago

analytics appear to be causing a pretty significant performance lag on the cli.

takes about 5-10 seconds for each cli command to respond -> this should not be blocking.

aaronjudd commented 7 years ago

This is a critical impact issue and needs an update. Can you please update the status?

jshimko commented 7 years ago

I need to figure out if this is geoip or Segment causing the wait, but I can at least move the call to the end of the command execution instead of the beginning. On my list for this week.

jshimko commented 7 years ago

So... it looks like this is on Segment's end. Here's the whole chunk of code that runs on our end...

// geoip fetch happens in milliseconds
const geo = await getGeoDetail();

// local fs
const userId = getUserId();

// define a few vars
const command = `${cmd} ${args}`.trim();
const argv = _.forEach(yargs.argv, (val) => !!val);

// get all dependency versions, happens in less than a second
const versions = getVersions();

// props to send to segment
const properties = { command, geo, ...argv, ...versions };

const analytics = new Analytics(segmentKey, { flushAt: 2, flushAfter: 20 });

// happens in milliseconds
analytics.identify({ userId, traits: { ...versions, geo } });

// takes 5-8 seconds
analytics.track({ event: 'command', userId, properties });

I don't know what could've changed in our account to cause this to happen, but it's clearly on Segment's end. I'll see if I can get some support from them. In the meantime, I moved this code to the end of the command execution so that it doesn't add the painful 5 sec wait to the beginning of every command. It's obviously still on the other end, but the experience is much less frustrating when your command is complete and you're just waiting for a prompt to come back.

Will follow up here once I know more. For now, 0.15.1 has much faster command execution.

brent-hoover commented 6 years ago

@jshimko Can you follow up on this and update this ticket?

jshimko commented 6 years ago

@zenweasel There are no updates on this ticket beyond the initial research I did above. Once somebody tells me this is top priority, I'll contact Segment and see if they can provide some insight. If that doesn't solve it, we can potentially add an endpoint in Launchdock to proxy that request in the job queue instead.

brent-hoover commented 6 years ago

@jshimko This ticket is already labeled "critical impact" so this is a top priority. Critical Impact bugs should always be handled before other work. Reassigning back to you.

jshimko commented 6 years ago

This should be resolved with reaction-cli@0.27.0. The Node lib for Segment wasn't flushing its in-memory cache as expected (based on their batching docs), so I added a manual cache flush that eliminated the fallback timeout.

To test, install 0.27.0 and run any command. You should see it end nearly immediately after the main process of the command completes.

cc: @zenweasel @aaronjudd

jshimko commented 6 years ago

This has been confirmed fixed in 0.27.0.