Giter VIP home page Giter VIP logo

supermetrics's Introduction

Supermetrics project

Performance

  • It has a linear execution time depending on the number of posts on cold start and logarithmic on hot start.
  • Memory usage is constant, no changes when the number of posts increases.
  • The level of memory usage on cold start may be adjusted by urls chunk size (the number of links that requested in parallel, now 5 links).

Perfomance

Results

PEST test

PSALM result

Features

  • NO use of existing frameworks (created NanoFramework just for task)
  • NO use of external modules/libraries
  • Docker container for php8 & composer
  • GitHub Actions CI\CD
  • Composer & PSR autoload
  • Curl multi execution, query urls in parallel
  • Custom exceptions
  • PSR Logs/Cache
  • SPL FixedArray
  • DB - file/table for a yielding reading by rows
  • Console colored prints to the screen
  • Psalm static analysis tool
  • PHPUnit + PEST tests

Program steps

Cold start

  1. Get token for user & put it to the user cache (1 hour)
  2. Generate urls chunks (by 5 links)
  3. Send each chunk to the http client
  4. For each chunk, get multiple links results in parallel
  5. Save each chunk results to the DB in append mode (cache for 1 minute, posts may change)
  6. Start reading from DB by row/post
  7. Send each post to Statistic calculator that aggregate data

Hot start

  1. Start reading from DB by row/post
  2. Send each post to Statistic calculator that aggregate data

Clone app

$ git clone https://github.com/GeorgII-web/supermetrics

Run locally (required php8 & composer)

Install

$ cp config.example.php config.php
$ composer install

Change config values.

Run

$ php command statistics
$ php command help
$ php command cache clear

Or run in docker

Install docker

$ docker-compose up -d --build
$ docker exec -it supermetrics_php bash

Install in the docker bash

$ cp config.example.php config.php
$ composer install

Change config values.

Run in the docker bash

$ php command statistics
$ php command help
$ php command cache clear

Additionally

$ php ./vendor/bin/psalm
$ php ./vendor/bin/pest

supermetrics's People

Contributors

georgedeploy avatar georgii-web avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.