This document discusses using reactive programming with Scala and Akka to build distributed, concurrent systems. It describes using the actor model and message passing between actors to develop scalable and resilient applications. Key points covered include using actors to build a web scraping system, handling failures through supervision strategies, and testing actor systems.
A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.
A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.
The Scala programming language has been gaining momentum recently as an alternative (and some might say successor) to Java on the JVM. This talk will start with an introduction to basic Scala syntax and concepts, then delve into some of Scala's more interesting and unique features. At the end we'll show a brief example of how Scala is used by the Lift web framework to simplify dynamic web apps.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Slides from my talk at the Feb 2011 Seattle Tech Startups meeting. More info here (along with powerpoint slides): http://www.startupmonkeys.com/2011/02/scala-frugal-mechanic/
Scala is a programming language that mixes object oriented and functional programming in a powerful and flexible way. While it can not be considered as a mainstream language, it has seen a growing adoption trend.An important ingredient for this diffusion is its complete interoperability with Java and the fact that it runs on a solid platform such as the JVM.
It is currently the 4th most loved programming language and the 2nd top paying technology of 2016 (StackOverflow Developers Survey).
These slides have been used for a 4h seminar at the University of Cagliari the 17th of December 2016
I used these slides for a Scala workshop that I gave. They are based on these: http://www.scala-lang.org/node/4454. Thanks to Alf Kristian Støyle and Fredrik Vraalsen for sharing!
Spring Data Requery is alternatives of Spring Data JPA
Requery is lightweight ORM for DBMS (MySQL, PostgreSQL, H2, SQLite, Oracle, SQL Server)
Spring Data Requery provide Query By Native Query, Query By Example and Query By Property like Spring Data JPA
Spring Data Requery is better performance than JPA
Reactive Programming, Traits and Principles. What is Reactive, where does it come from, and what is it good for? How does it differ from event driven programming? It only functional?
The Scala programming language has been gaining momentum recently as an alternative (and some might say successor) to Java on the JVM. This talk will start with an introduction to basic Scala syntax and concepts, then delve into some of Scala's more interesting and unique features. At the end we'll show a brief example of how Scala is used by the Lift web framework to simplify dynamic web apps.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Slides from my talk at the Feb 2011 Seattle Tech Startups meeting. More info here (along with powerpoint slides): http://www.startupmonkeys.com/2011/02/scala-frugal-mechanic/
Scala is a programming language that mixes object oriented and functional programming in a powerful and flexible way. While it can not be considered as a mainstream language, it has seen a growing adoption trend.An important ingredient for this diffusion is its complete interoperability with Java and the fact that it runs on a solid platform such as the JVM.
It is currently the 4th most loved programming language and the 2nd top paying technology of 2016 (StackOverflow Developers Survey).
These slides have been used for a 4h seminar at the University of Cagliari the 17th of December 2016
I used these slides for a Scala workshop that I gave. They are based on these: http://www.scala-lang.org/node/4454. Thanks to Alf Kristian Støyle and Fredrik Vraalsen for sharing!
Spring Data Requery is alternatives of Spring Data JPA
Requery is lightweight ORM for DBMS (MySQL, PostgreSQL, H2, SQLite, Oracle, SQL Server)
Spring Data Requery provide Query By Native Query, Query By Example and Query By Property like Spring Data JPA
Spring Data Requery is better performance than JPA
Reactive Programming, Traits and Principles. What is Reactive, where does it come from, and what is it good for? How does it differ from event driven programming? It only functional?
Over the past few years, web-applications have started to play an increasingly important role in our lives. We expect them to be always available and the data to be always fresh. This shift into the realm of real-time data processing is now transitioning to physical devices, and Gartner predicts that the Internet of Things will grow to an installed base of 26 billion units by 2020.
Reactive web-applications are an answer to the new requirements of high-availability and resource efficiency brought by this rapid evolution. On the JVM, a set of new languages and tools has emerged that enable the development of entirely asynchronous request and data handling pipelines. At the same time, container-less application frameworks are gaining increasing popularity over traditional deployment mechanisms.
This talk is going to give you an introduction into one of the most trending reactive web-application stack on the JVM, involving the Scala programming language, the concurrency toolkit Akka and the web-application framework Play. It will show you how functional programming techniques enable asynchronous programming, and how those technologies help to build robust and resilient web-applications.
Nowadays Akka is a popular choice for building distributed systems - there are a lot of case studies and successful examples in the industry.
But it still can be hard to switch to actor-based systems, because most of the tutorials and documentation don't show the way to assemble a real application using actors, especially in microservices environment.
Actor is a powerful abstraction in the message-driven environments, but it can be challenging to use familiar patterns and methodologies. At the same time, message-driven nature of actors is the biggest advantage that can be used for Reactive systems and microservices.
I want to share my experience and show how Domain-Driven Design and Enterprise Integration Patterns can be leveraged to design and build fine-grained microservices with synchronous and asynchronous communication. I'll focus on the core Akka functionality, but also explain how advanced features like Akka Persistence and Akka Cluster Sharding can be used together for achieving incredible results.
During the talk, we will build a simple web app using Lift and then introduce Akka ( http://akkasource.org) to help scale it. Specifically, we will demonstrate Remote Actors, "Let it crash" fail over, and Dispatcher. Other Scala oriented tools we will use include sbt and ENSIME mode for emacs.
Building large scale, job processing systems with Scala Akka Actor frameworkVignesh Sukumar
The Akka Actor framework is designed to be a fast message processing system. In this talk, we will explain how, at Box, we have used this framework to develop a large scale job processing system that works on billions of data files and achieves a high degree of throughput and fault tolerance. Over the course of the talk, we will explore the usage of Akka framework’s Supervisor functionality to provide a more controllable fault-tolerance strategy, and how we can use Futures to manage asynchronous jobs.
Using Groovy? Got lots of stuff to do at the same time? Then you need to take a look at GPars (“Jeepers!”), a library providing support for concurrency and parallelism in Groovy. GPars brings powerful concurrency models from other languages to Groovy and makes them easy to use with custom DSLs:
- Actors (Erlang and Scala)
- Dataflow (Io)
- Fork/join (Java)
- Agent (Clojure agents)
In addition to this support, GPars integrates with standard Groovy frameworks like Grails and Griffon.
Background, comparisons to other languages, and motivating examples will be given for the major GPars features.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
2. About us
• Lior Shapsa – Leads Benchmark Development (lshapsa@vmware.com)
• Yardena Meymann - Group Architect (ymeymann@vmware.com)
2
3. The Project
• New Generation Business Management Products
• Manage Financial Aspects of the Cloud
• Help CFOs to optimize the cloud cost
• Benchmarking – Compare to Industry Best Practices
3
4. What Do We Need
• Web Scraping – naïve way isn’t good enough
• Crowd Sourcing
• Analyze Data
– Build a reliable price list
– How efficient is my virtual infra vs. industry? (cost, capacity)
– How fast am I responding to business challenges
• Start With Single Instance and Scale Out Fast!
5. Why to Scale Out
Moore’s Law
• The Clock Speed Has
Reached Its Limit in 2006
• Free Lunch Is Over
6. Why to Scale Out
Amdahl’s Law
• The New Reality
http://en.wikipedia.org/wiki/Amdahl's_law
7. The Challenge
Shared mutable state -> race conditions
Threads are
expensive
Locks are hard
(and expensive)
8. The Challenge
8 Fallacies of Distributed Computing:
– The network is reliable
– Latency is zero
– Bandwidth is infinite
– The network is secure
– Topology doesn't change
– There is one administrator
– Transport cost is zero
– The network is homogeneous
9. Reactive Programming
• React to Events
– Pushing rather than pulling (No Shared State)
• React to Load
– Focus on scalability rather than single-user performance.
• React to Failure
– Resilient systems with the ability to recover quickly at all levels.
• React to Users
– Combine the above traits for an interactive user experience
9
10. Chosen Solution: Actor Model
• Formalized in 1973 by Carl Hewitt and refined by
Gul Agha in mid 80s.
– The first major adoption is done by Ericsson in mid 80s.
• Invented Erlang and later open-sourced in 90s.
• Built a distributed, concurrent, and fault-tolerant
telecom system which has 99.9999999% uptime
11. Chosen Solution: Actor Model
• Actor Instead of Object, Asynch Message Instead of Method Call
• Keep Mutable State Internal, Share Nothing
• Communicate via Immutable Message Passing
• Messages are Kept in Mailbox and Processed Sequentially
• Asynchronous and Non-blocking
Actor Actor
Mailbox
state
Mailbox behavior
behavior state
12. Actor Example (Scala)
• Define
case class Greeting(who: String) //message
class GreetingActor extends Actor {
def receive = {
case Greeting(who) => sender ! “Hello ” + who
}
}
• Create
val sys = ActorSystem("MySystem")
val greeter = sys.actorOf(Props[GreetingActor], "greeter")
• Send
greeter ! Greeting(“Akka”);
13. Actor Libs For the JVM
• Akka (Java/Scala)
• Kilim (Java)
• Jetlang (Java)
• Actor’s Guild (Java)
• Actorom (Java)
• FunctionalJava (Java)
• GPar (Groovy)
15. Dispatch
Crawling
library
Netty
Web Scraping Actors Design
Curiosity
Site …
Pages
Level1 Level1
Level2
…
Level2
File
writer
Site
…
k/v
16. Example Site
class Servers extends Site {
override def start(): Unit = goto[ListPage] “…”
}
class ListPage extends Page {
override def processResult(result: Response): Unit = {
val links = listProductLinks(result.content)
links foreach goto[ProductPage](_, pageType = Child)
val next = getNextPage(result.content)
next foreach goto[ListPage](_, pageType = Sibling)
}
}
class ProductPage extends Page {
override def processResult(result: Response): Unit = {
val spec = productTitle(result.content) ++
generalSpec(result.content) ++
pricingInfo(result.content)
writeToFile(spec)
}
}
17. Supervision
• Let It Crash!
– Errors are encapsulated as messages and isolated from the BL
– The caller is not necessarily available
• The Supervisor Reacts Upon Failure
– Resume, keeping its accumulated internal state
– Restart, clearing out its accumulated internal state
– Terminate
– Escalate
18. Supervision – Example (optional)
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10,
withinTimeRange = 1 minute) {
case _: ArithmeticException => Resume
case _: NullPointerException => Restart
case _: Exception => Escalate
}
19. Akka Distributable by Design
• Superior model for detecting and recovering from errors
• Location transparent - scale UP and OUT for free
• Adaptive load-balancing, cluster rebalancing & actor
migration
• Build extremely loosely coupled and dynamic systems
that can change and adapt at runtime
21. Receive Method
• Pattern match on the message
class Site… extends Actor … {
override def receive: Receive = {
case Start =>
log.info(s"Starting $siteName ...")
start()
…
}
• Defined for some (but not necessarily all) messages
• Unhandled messages are sent to a special location
22. Splitting Behavior Between Methods
• Group related messages in a receive function
• Compose receive functions with orElse operator
private def process: Receive = {
case res: Response => …
case Status.Failure(e) => …
}
private def monitor: Receive = {
case Create… => …
case Terminated(actor) => …
Curiosity
Site …
Crawler
Crawling
library
}
protected override def receive: Receive = process orElse monitor
Netty
Pages
Page
Page
Page
…
Page
File writer
Site
…
23. Using Traits to Compose a Behavior
trait Percolator { myself: Actor =>
protected def percolate: Receive = …
}
trait Composite { myself: Actor =>
protected def monitor: Receive = …
}
class Page extends Actor with Percolator with Composite {
private def process: Receive = …
protected override def receive =
process orElse percolate orElse monitor
}
Composite Percolator
Actor
Page
c
t t
c
24. Web Scraping Actors Design
Curiosity
Dispatch
Crawling
library
Netty
Site …
Pages
Level1 Level1
Level2
…
Level2
File
writer
Site
…
25. Propagate Messages
You can forward messages without understanding them, “methodMissing”
trait Percolator { myself: Actor =>
protected def percolate: Receive = {
case _ => parent forward msg
}
class Site… extends Actor {
protected def override receive: Receive = {
case msg: Goto => crawler forward msg
case msg: WriteFile => writer forward msg
}
26. Futures
• Future holds a value which may become available at some point
– completed when the computation results in a value or an exception
• java.util.concurrent has futures, but we can do better…
• Scala’s futures are asynchronously compose-able
– Callbacks: onSuccess, onFailure, onComplete
val f: Future[List[String]] = future { session.getRecentPosts }
f onFailure {
case e => println("An error has occurred: " + e.getMessage)
}
f onSuccess {
case posts => for (post <- posts) println(post)
}
• More and more API’s are non-blocking - returning futures
27. Tell vs Ask
• Tell, a.k.a. !
– Fire & forget
– Best concurrency and scalability
• Ask, a.k.a. ?
– sends and (optionally) wait for reply
– uses delayed computation (Futures)
– combining futures and actors – pipeTo trick
import akka.pattern.pipe
val page: ActorRef = …
val f: Future[xml.NodeSeq] = Http.browse(url(…) OK as.tagsoup.NodeSeq)
f pipeTo page
• Why we decided to stick with “bare actors”
28. A Closer Look at Akka Actor
Reference
Instance
Instance
factory
Context
Mailbox
Receive function
Receive function
Behavior
29. Actor State
It’s Ok to have mutable state inside actor
trait Composite { myself: Actor =>
private var childrenCount = 0
override def receive: Receive = {
case Created… =>
childrenCount = childrenCount + 1
case Terminated… =>
childrenCount = childrenCount – 1
if (childrenCount == 0) context stop self
}
30. Lightweight State-Machine with become
class Curiosity extends Actor {
private def free: Receive = {
case Start =>
crawlers foreach (_ ! Start)
context become busy
case Status | Stop => sender ! Free
}
private def busy: Receive = {
case Stop =>
crawlers foreach (_ ! Stop)
context become awaitingTermination
case Status | Start => sender ! Busy
case AllFinished => context become free
}
private def awaitingTermination: Receive = {
case AllFinished => context become free
case Status | Start | Stop => sender ! Busy
}
override def receive: Receive = free
}
Free
Busy
Start
Awaiting
Termination
Stop
Finished
Finished
31. Actor Hierarchy DO’s and DON’Ts
• DO give actors meaningful names if you can
• DON’T be afraid to create lots of short-living actors
• DON’T nest actor classes in one another
• DO note that restart that results from failure is not the same as a
graceful stop
• DON’T define public methods on Actors
• DO choose supervision strategy wisely, build your hierarchy according
to the strategy
• DON’T confuse actor.Status.Failure with util.Failure
• DO make sure messages are immutable
• DON’T rely on using generics in messages, as they will be erased in
bytecode (unless you reify with ClassTag/TypeTag)
32. Stopping Actors
• Watching another actor – Death Watch
– Not same as supervision
– Use context.watch(actorReference)
– Terminated(actorReference) events
• Stop vs. PoisonPill and how we used both
– context.stop – terminate after current message
– context.kill – terminate now
– PoisonPill message – terminate after processing all messages
33. Web Scraping - Termination
Curiosity
Dispatch
Crawling
library
Netty
Site …
Pages
Page Page
Page
…
Page
File
writer
Site
…
k/v k/v k/v
37. Testing Akka - Example
import org.scalatest._
import akka.testkit.{ImplicitSender , TestActorRef, TestKit}
class CuriosityTest extends TestKit(new ActorSystem(“…”) … {
val myTestedActor = TestActorRef[Curiosity]
“Curiosity" must {
"display free status when not working" in {
myTestedActor ! Status
expectMsg(Free)
}
}
…
}
Benchmark cloud cost, efficiency and capacity
Benchmarking module is written 100% in Scala 2.10.
Backend is based on Typesafe stack (SBT, AKKA, Spray, Play), HDFS, Spark, MongoDB, Lucene, etc…
Frontend is based on HTML 5 and AngularJS
Web Scraping
Collect updated inventory and costs of Servers, OSs, CPUs, Labor, Storage, etc…
Use reliable techniques to extract cost and specifications out of the web pages
Crowd Sourcing
Collect users inventory and costs to build better costing functions
Validation, masking, filtering, encryption, compression
Analyze
Build a reliable price list
How efficient is my virtual infra vs. industry? (cost, capacity)
How fast am I responding to business challenges
http://www.reactivemanifesto.org/#event-driven
Free - high CPU utilization, low latency, high throughput and scalability
sends a message asynchronously and returns a Future representing a possible reply
More neat tricks: stashing messages, full-blown state-machines
More neat tricks: stashing messages, full-blown state-machines