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

First loading is slow #1

Open
huoyijie opened this issue Sep 4, 2023 · 1 comment
Open

First loading is slow #1

huoyijie opened this issue Sep 4, 2023 · 1 comment
Assignees

Comments

@huoyijie
Copy link
Owner

huoyijie commented Sep 4, 2023

When open https://huoyijie.github.io/infinity in the browser, the page shows loading and is very slow.

@huoyijie huoyijie self-assigned this Sep 4, 2023
@huoyijie
Copy link
Owner Author

huoyijie commented Sep 5, 2023

  1. The server will emit drawings to client on every new connection, and I have changed to emit strokes which
    reduced redundant data. (sync strokes cost reduced from 6s to 3s)
socket.emit(
  'strokes',
  strokes,
  () => console.log(socket.id, 'sync strokes cost', new Date().getTime() - t, 'ms')
);
  1. Add 'perMessageDeflate: true' option to compress messages (sync strokes cost reduced from 3s to 2s)
const io = new Server(httpServer, {
  // Add 'perMessageDeflate: true' option to compress messages
  perMessageDeflate: true,
  parser: msgpackParser,
  serveClient: false,
  path: path.join(basePath, 'socket.io'),
  cors: { origin }
});

If possible, I will continue to optimize the table structure, reduce redundant data storage and transmission in the future.

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