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

Initialize this backend #1

Open
waghanza opened this issue Oct 15, 2019 · 53 comments
Open

Initialize this backend #1

waghanza opened this issue Oct 15, 2019 · 53 comments

Comments

@waghanza
Copy link
Contributor

Hi @ohler55,

We need a backend to get some results. The best (I think) is GraphQL since it allow end-user to create custom queries.

Would you mind to initialize a project (using agoo) that is a GraphQL API to discover our results.

I don't know how to code with agooo, could you please initialize this project with activerecord, I'll create migration ... to define the model so as @doanguyen could work on frontend part.

I ❤️ collaboration

@ohler55
Copy link
Contributor

ohler55 commented Oct 15, 2019

Sounds like fun. I'll have to brush up on activerecord.

Where or how to you plan to have the result data stored?

Do you have a host for the server once we get it setup?

@waghanza
Copy link
Contributor Author

probably, this will be run on https://heroku.com (probably some other host later) and results will be store in any postgresql database, actually I've choose https://www.elephantsql.com/

@ohler55
Copy link
Contributor

ohler55 commented Oct 15, 2019

Okay, I'll look at active record in association with elephantsql. Do you plan on serving historical data as well or just the current data?

@waghanza
Copy link
Contributor Author

elephansql is just a postgresql ;-) the main idea is to have a non-local database

actually, due to some limitations, only the last data need to be displayed

@ohler55
Copy link
Contributor

ohler55 commented Oct 15, 2019

If it is the last set of data only, is there really a need for an SQL database or is that just to be able to play with the database?

@waghanza
Copy link
Contributor Author

I understand you. A flat json file could be enough, but the purpose is to have a more flexible solution (add scenarios, multiple rounds ... but in the future)

@ohler55
Copy link
Contributor

ohler55 commented Oct 15, 2019

Fair enough.

@doanguyen
Copy link
Member

Hi,

after tinkering a bit on gridsome, I think the graphql on the server-side is redundant since gridsome has another layer of graphql for itself.

So it's just a matter of taste if you guys wanted to use graphql on the server-side, I'll rather not use gridsome on the client-side.

@ohler55
Copy link
Contributor

ohler55 commented Oct 16, 2019

I think having GraphQL on the client side negates some of the espoused benefits of GraphQL. If GraphQL is going to be used it seems like the server side is the place for it. At least thats my opinion.

@waghanza
Copy link
Contributor Author

waghanza commented Oct 16, 2019

@doanguyen gridsome is just the client side. the advantage of using a client-side framework is that the server-side could be explored ?

honestly, this can be done with a REST API, but there is two things to consider :

  • REST is not flexible as we can create custom query without development (can not explorer API)
  • GraphQL could be great to learn a new way of development (at least for me) and help @ohler55 in building agoo

@doanguyen Anything could be acceptable, however, I truly think GraphQL (server-side) is the best way for us

@doanguyen
Copy link
Member

Yes, I fully support Graphql as well since I also wanted to know more about it. As consequence, there is no need to use gridsome at the frontend (it brings a lot of overhead), and I will start with a bare-bone react/vuejs project.

@waghanza
Copy link
Contributor Author

ok, feel free to choose (I prefer vuejs but if YOU prefer react I'm ok to learn it)

@ohler55
Copy link
Contributor

ohler55 commented Oct 20, 2019

I was about to get started on this but noticed there are no files in the repo yet. Any reason I shouldn't get it started?

@waghanza
Copy link
Contributor Author

This is linked with the-benchmarker/web-frameworks#1774. I am about to finish this issue, so I can push some database models here.

I do not know about agoo, so I have started with activerecord to design database

@ohler55
Copy link
Contributor

ohler55 commented Oct 20, 2019

No worries. I can work with what you have once you push it.

@waghanza
Copy link
Contributor Author

I've pushed some code, you need thus to have one postgresql benchmark name benchmark and start with

bundle install
bundle exec rake db:migrate

@ohler55
Copy link
Contributor

ohler55 commented Oct 20, 2019

I assume you mean one table named benchmark. Any particular structure to the table?

Before that though, I haven't spend much time with postgres. Do you have a conf file to use or some hints on how to get set up from scratch?

@ohler55
Copy link
Contributor

ohler55 commented Oct 20, 2019

I'd like to change the default branch to develop also so we follow a conventional git development process. Basically branch off the develop branch for new features or bug fixes and release on the master branch.

@waghanza
Copy link
Contributor Author

Feel free to change 😛 (even without asking, I'll adapt)

BTW, it's a good idea to use 2 branches git workflow for apps

@waghanza
Copy link
Contributor Author

also semver ;-)

@ohler55
Copy link
Contributor

ohler55 commented Oct 20, 2019

Exactly.

@ohler55
Copy link
Contributor

ohler55 commented Oct 20, 2019

Added a Agoo GraphQL hookup. Dummy data not hooked up to the database. Should let you see what the GraphQL would look like. Feel free change the attributes. I'd suggest named metrics in the framework instead of a generic Metric class. The frontend will be happier to have named attributes and not an array of key value pairs.

@waghanza
Copy link
Contributor Author

Having name metrics could lead to more maintenance. The idea is to have NO devs to do here, when adding any metric in https://github.com/the-benchmarker/web-frameworks.

@ohler55
Copy link
Contributor

ohler55 commented Oct 21, 2019

There are tradeoffs with generic metrics vs metric attributes. If you prefer generic I'll work with that.

I was disappointed to see that request rates are no longer shown on the web-frameworks landing page. Why did you get rid of that? Seems like that is the best indicator of how much load a framework can handle.

@waghanza
Copy link
Contributor Author

request rates

what do you mean ? I have kept req/s right ?

I have change the layout just for presentation, but data are collected

@ohler55
Copy link
Contributor

ohler55 commented Oct 21, 2019

Odd, it's back now. I do see Agoo-c dropped. I'll have to see what happened.

@waghanza
Copy link
Contributor Author

agoo-c is still here (on top now as this list is order by average latency now)

@ohler55
Copy link
Contributor

ohler55 commented Oct 21, 2019

I liked having the req/s sort for obvious reasons. :-)

@waghanza
Copy link
Contributor Author

Yes, some want to sort by some values, and other for somes ...

Having a separated frontend is the solution for this kind of problem 😛

@ohler55
Copy link
Contributor

ohler55 commented Oct 28, 2019

Just pushed backend that has GraphQL access to one class, Language. Just a start but pretty confident I know how to take it further. Anyway, I think we need to discuss the models at some point. I don't think the proposed model is going to be very easy for the frontend to work with and it kind of defeats some of the benefits of using GraphQL by using the generic metric and values.

I'd be very glad to explain my reasoning if you are interested.

@waghanza
Copy link
Contributor Author

Hi @ohler55,

I think that you are saying will had more complexity, but feel free to write the code. I have no time (in short term) to do this. So I let you do it 😛

No matter what, I'll met you at some point (I mean modifying https://github.com/the-benchmarker/web-frameworks to fit this project requirements is not a big deal).

Regards,

@waghanza
Copy link
Contributor Author

fell free to play with fake data

@ohler55
Copy link
Contributor

ohler55 commented Oct 29, 2019

Will do. I could implement both approaches and we can then compare. I am also strapped for time so it will be a slow process initially.

@waghanza
Copy link
Contributor Author

no matter of time 😛 I prefer to be slow but careful in this case

it could be very good to implement both, up to you, but will be ❤️

@waghanza
Copy link
Contributor Author

@ohler55 I think having a specific backend here could be hard to maintain.

I think of using https://hasura.io as the back end layer.

What do you think ?

@ohler55
Copy link
Contributor

ohler55 commented Jan 10, 2020

Funny I was talking to a fellow yesterday about this application, the benchmarked that is. He does a lot of front end work but also deals with backends. His suggestion was go simple with just JSON data file. I see you are leaning in the other direction and adopting a fairly substantial backend infrastructure.

I'm probably biased as I would like to exercise Agoo GraphQL so that would be my preference since the object model is pretty trivial but I know you had mentioned that this was more of a change to use different technologies. I't had for me to recommend as I'm not sure what your requirements or desires are. I had planned to ping you later tonight to see if we could get this moving again and maybe take a step back and identify the requirements and then look at the desired architecture. So good timing. 😄

If you can list out the requirements, including the obvious of wanted to display the benchmark data I can do my best to remain unbiased and help you decide.

@waghanza
Copy link
Contributor Author

The purpose is to have the simplest way to query results of https://github.com/the-benchmarker/web-frameworks

The thing is that results is store in a database, and, in my opinion, the more efficient way to get them (in this context) is to have a GraphQL engine. The idea of using agoo, is that you have an exercise on doing so ... I'm not against it

So, there is :

  • on one hand, a promotion app of agoo
  • on other hard, an opensource engine

The hard point here is maintenance.

If you think you have enough time to create this app, I be please ❤️

@ohler55
Copy link
Contributor

ohler55 commented Jan 10, 2020

I do have the time. We had some differences on the use of the SQL database. If you are up for it lets discuss that or is that not up for discussion? It is something that would be applicable even if using a different backend.

@ohler55
Copy link
Contributor

ohler55 commented Jan 11, 2020

Let me jot down some thoughts on architecture. See if we are in sync.

There are three components in the system; the benchmarker, a results server, and a presentation component. Ideally there would be just two API to deal with. One between the benchmarker and the server and another between the server and the UX. Adding a third between the benchmarker and UX would not be ideal and should be avoided.

Benchmarker - Server API

The API is from benchmarker to server and the data is static. Among the options for providing the data to the server are:

  • the current README.md
    While simple it use GitHub as the server and static displays of the data. It does not support sorting nor some more dynamic features found in modern web applications.

  • a JSON data file or files
    Very simple to implement. Files could be provide on GitHub. The data could be processed in Javascript in the UX. The drawback of this approach is it does not server as a demonstration of how to use GraphQL and database integrations. It could be used to demonstrate just GraphQL use though.

  • a no-SQL database such as MongoDB
    JSON is a natural fit to GraphQL and also to the grouped results from the benchmarker. With a MongoDB Ruby driver integration would be simple. Rails could be used but would not provide any additional features.

  • an SQL database such as ElephantSQL
    SQL is often used with Rails or at least ActiveRecord so it would serve as a good example of how a larger project might be implemented. It has the advantage of having database schemas that describe the API.

  • a key value store such as Redis
    A key value store is very flexible but it requires additional documentation to described the keys and how values should be converted. If the key/value model is propagated through to the UX then a document heavy API is needed between the benchmarker and the UX which should be avoided.

Of the outlined options the SQL database was chosen. Next the table definitions are needed. Typically tables are normalized to reflect the concerns of the data being stored. In this case benchmark results and the frameworks associated with each result so a single table would be sufficient with one row per result and multiple columns with each type of result value.

The API between the server and the UX should be based on an object model that matches the user's conception of the system or in this case benchmarks. That will make building the UX more straight forward. Ideally the model should be fairly close to the way the data is presented in the benchmarker to server API. In this case that is possible although in some more complex systems there may be some variations.

For benchmark results a model can be defined that can be used for both the server to UX API as well as the benchmarker to server API (database). The APIs can be defined with an annotated table definition and a GraphQL schema file.

Comments? Agree or disagree?

@waghanza
Copy link
Contributor Author

For benchmark results a model can be defined that can be used for both the server to UX API as well as the benchmarker to server API (database). The APIs can be defined with an annotated table definition and a GraphQL schema file.

How can it be done ?

This feature could reduce complexity, and allow either backend and benchmarker to grow separately

@ohler55
Copy link
Contributor

ohler55 commented Jan 12, 2020

Using GraphQL syntax the results might look like this assuming we decide Result is the name of the type:

type Result {
  language: String! # better to make Language but this gets the point across more simply
  framework: String!
  rate: Float
  medianLatency: Float
  averageLatency: Float
  latency90: Float
  latency99: Float
}

A change in the schema would have to be reflected in both the database schema and in the GraphQL. Following that the Ruby classes would be updated but the Ruby classes just pass along data from the ActiveRecord wrappers so there would not be a lot of code to say add a new metric to the benchmarks. Of course I can't speak for what changes would be needed in the UX.

I hadn't looked at the results in a while. I noticed significant changes so the suggestion above might need reworking depending on what you have in mind.

@waghanza
Copy link
Contributor Author

Ok. I see.

The idea is to share this code so as results production and UX could be totally isolated.

I like the idea, but I'm not capable of doing such a thing.

I propose to create a usable GraphQL model in benchmark repo. Feel free to propose me something, and I will make sure this is in-sync with data model, so as you can pick this file as a basis for backend.

Regards,

PS : I think having this shared part of code could be avoided using https://jsonapi.org/ thus

@ohler55
Copy link
Contributor

ohler55 commented Jan 13, 2020

Happy to fill out a GraphQL schema. Personally I'd skip the addition of another format for API definitions and translations to GraphQL and table definitions and just go straight from GraphQL to table definition. GraphQL is meant to be a description of an API so ideally it should be sufficient for that. Of course that would mean we need a tool to go from GraphQL to table definition. That might be a useful addition to Agoo so glad to provide that either as part of Agoo or separate.

@ohler55
Copy link
Contributor

ohler55 commented Jan 14, 2020

I created a PR with the GraphQL schema. Please take a look and comment.

@waghanza
Copy link
Contributor Author

waghanza commented Mar 3, 2020

@ohler55 will it be convenient for you if I create a gem that contains the whole database structure (models, migrations ...)?

@waghanza
Copy link
Contributor Author

waghanza commented Mar 3, 2020

and of course an up-to-date GraphQL schema

@ohler55
Copy link
Contributor

ohler55 commented Mar 3, 2020

I can get started on that next week. This week is packing for a move.

@waghanza
Copy link
Contributor Author

waghanza commented Mar 3, 2020

I mean, that I can create a gem with all database definition included (and graphql schema).

will it be helpful @ohler55 ?

@ohler55
Copy link
Contributor

ohler55 commented Mar 4, 2020

That would be extremely helpful.

@waghanza
Copy link
Contributor Author

waghanza commented Mar 4, 2020

Ok, will do

BTW, I will switch to ruby to have quicker features addition

@ohler55
Copy link
Contributor

ohler55 commented Mar 4, 2020

You mentioned creating a gem. Is that needed or just put the Ruby code in this project.

@waghanza
Copy link
Contributor Author

waghanza commented Mar 4, 2020

I will create this gem 😛 it will only contains models, it will be a way for both project to share the data modelization

@ohler55
Copy link
Contributor

ohler55 commented Mar 4, 2020

I forgot about that. Yes, multiple project. Great.

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

3 participants