Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reactive Programming - Efficient Server Applications

Reactive Programming - Efficient Server Applications

The second part of the presentation for "Hack Your Career" event organized by SAP Hybris company at Silesian University of Technology in Gliwice, Poland

Slides are supportive for further live coding.
Code samples from this part the presentation are available at:
- https://github.com/pwittchen/reactive-client-server
- https://github.com/pwittchen/java-flow-experiments

Piotr Wittchen

November 08, 2017
Tweet

More Decks by Piotr Wittchen

Other Decks in Programming

Transcript

  1. INTERNAL
    Piotr Wittchen, Arkadiusz Galwas, SAP Hybris
    Reactive Programming
    Efficient Server Applications

    View Slide

  2. Let’s plan an application

    View Slide

  3. 3
    INTERNAL
    © 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ
    Basic application flow
    Client
    Data Acquisition
    Reading data from sensors.
    Client
    Sending Data
    Sending data from the Client
    to the Server over HTTP
    protocol.
    Server
    Data Handling
    Handling incoming data
    received from the Client.
    Server
    Data Processing
    Processing handled data and
    logging them.

    View Slide

  4. 4
    INTERNAL
    © 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ
    Flow of the data streams inside the application
    1
    Stream
    of Sensor Events
    Data
    acquired
    on
    a
    m
    obile
    device
    2
    Stream
    of HTTP
    Requests
    Data
    sent from
    the
    client to
    the
    server
    3
    Stream
    of HTTP
    Responses
    Data
    received
    by
    the
    server
    Continuous stream of the data without breaking a chain

    View Slide

  5. 5
    INTERNAL
    © 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ
    Technologies we are going to use
    ● Server
    ○ Gradle
    ○ Java 9
    ○ RxJava 2
    ○ Vert.x
    ■ Core
    ■ Rx
    ○ Logback
    ● Client
    ○ Gradle
    ○ Android
    ○ Java 7
    ○ Retrolambda
    ○ RxJava 2
    ○ RxAndroid
    ○ OkHttp 3
    ○ ReactiveSensors
    Side note
    This is just a simple demo with the only one endpoint.
    For more endpoints it’s better to use
    Vertx-web on the server and Retrofit on the client.

    View Slide

  6. Let’s make an application!

    View Slide

  7. 7
    INTERNAL
    © 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ
    Source code of this project can be found at:
    https://github.com/pwittchen/reactive-client-server/

    View Slide

  8. Optimizing CPU usage with RxJava

    View Slide

  9. 9
    INTERNAL
    © 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ
    Optimizing CPU usage
    Core Core
    thread thread thread thread
    If we are not using all available cores efficiently, we’re wasting resources and applications are getting slow.
    CPU

    View Slide

  10. View Slide

  11. 11
    INTERNAL
    © 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ
    Source code of this project can be found at:
    https://github.com/pwittchen/java-flow-experiments

    View Slide

  12. Thank you
    Contact information:
    Piotr Wittchen, Arkadiusz Galwas
    [email protected], [email protected]
    Software Developers
    SAP Hybris

    View Slide