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

Improve performance of php<->js communication #28

Closed
ayavilevich opened this issue Feb 28, 2021 · 2 comments
Closed

Improve performance of php<->js communication #28

ayavilevich opened this issue Feb 28, 2021 · 2 comments
Assignees

Comments

@ayavilevich
Copy link
Collaborator

This communication is used to access the EI API.

Relevant files:
js/egg-inc.js
app/Api/EggInc.php

Currently every request is sync and invokes the node from php via a shell execution.
So web requests seem to be in series and not parallel, plus there is overhead of process invokation.

Perhaps the best solution would be to make the EI API calls in PHP.

protobuf also has PHP libs:
https://developers.google.com/protocol-buffers/docs/reference/php-generated
https://github.com/protobuf-php/protobuf

Can even do a "stale ok" caching strategy where if data for the user exists it is returned and then an async call is made to refresh the data in cache for next time.

However, for now we are going to do a hybrid solution but one that is parallel and has less overhead.

First, make a node webserver that can make the protobuf EI API requests and return json. It will be called by PHP over http, locally, without doing shell executions.
Second, have a method in the new web server that can fetch several user infos at once. Later use in PHP in an optimized manner.

@ayavilevich ayavilevich self-assigned this Feb 28, 2021
@ayavilevich
Copy link
Collaborator Author

@MoT3rror I have complete the new wrapper. Please take a look and give it a try. LMK if it works better.

https://github.com/MoT3rror/egginc-coop-tracker/tree/feature/interop-performance-boost

For now getPlayerInfos returns an array of individual getPlayerInfo responses (with payload.data schema). This can be changed if you prefer. For example, if it helps, can change it to an object where the id is the key and payload.data is the value.

@ayavilevich
Copy link
Collaborator Author

related to PR: #30

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

2 participants