In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about what Mesos Framework development is, many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.
Mesos introduction
Mesos's official website introduces itself as follows:
Program against your datacenter like it's a single pool of resources
Apache Mesos abstracts CPU, memory, storage, and other compute resources away from machines (physical or virtual), enabling fault-tolerant and elastic distributed systems to easily be built and run effectively.
The translation is:
Mesos makes your data center look like a pool of resources.
Apache Mesos abstracts CPU, memory, storage, and other computing resources from machines (physical or virtual machines), making fault-tolerant and resilient distributed systems easy to build and run effectively.
In popular terms, it is:
As the manager of all kinds of resources on the host, Mesos makes it easier for you to maintain and use these resources on Mesos for distributed running and management of programs.
For more detailed information, you can check the documentation on the official website.
Mesos Framework introduction
Mesos Framework consists of two parts:
Scheduler framing device
Executor actuator
Since Mesos is the manager of host resources, Scheduler in Framework is the scheduler of host resources, it is responsible for determining which resources are used to distribute which tasks, and Executor is the executor of the task, and it is really responsible for executing the running of the task.
Mesos abstracts the resources on the host into pieces of resource invitations (resources offer), and constantly sends them to the Scheduler registered on the Mesos with a specific role (role). Then after Scheduler gets the offer, it decline or accept the offer according to whether it is necessary for the task. If the offer is acceptable, tell Mesos Master how many resources I need to use and what kind of task to send. After a series of transfers, Mesos Master notifies the Executor running on each host to realize the task running on the host.
Framework Scheduler development
After understanding the general principle of Mesos Framework, you can try to develop Framework. This article mainly introduces the development of Scheduler.
There is a guide Framework Development Guide for Framework development in the documentation on Mesos's official website, and I have extracted the key points:
Framework development guide
For Scheduler development, there are two ways:
By implementing the SchedulerDriver C++ interface, an older version of Mesos 0.28.0 or is recommended.
With HTTP API, a newer version of Mesos 1.0 or is recommended
For the first approach, Scheduler developers implement custom scheduling logic by registering the event callback method. Because the SchedulerDriver interface is written in C++, this requires Scheduler developers to use the C++ language, while other languages use native libraries compiled by C++.
NameLanguageScheduler LibraryC++Scheduler Adapter (depends on native libmesos) Java
The second way is the usage recommended by the new version of Mesos. There are also many ready-made libraries in various languages. For more information, please see HTTP API client libraries.
Then we will introduce the environment construction of these two ways through the example program.
To ensure the scalability of multi-Scheduler, Mesos gives the following recommendations:
Using Suppress: after calling Suppress, Mesos no longer sends the resource Offer to Scheduler. When there are no tasks to be issued or no other operations on the offer, the Scheduler must maintain the suppressed state to ensure that the Mesos provides offer for other Scheduler more effectively.
Don't hold Offers for a long time: if some Offers is not needed by Scheduler, decline it immediately. Otherwise, these resource Offers cannot be made available to other Scheduler, and the resource offers received by itself will be reduced.
Deny the Decline resource Offers with a large timeout: when rejecting an offer, set a larger Filters.refuse_seconds timeout (for example, 1 hour). This ensures that Mesos has time to try to provide resource offers to other Scheduler (the authors believe that this time requires a case-by-case analysis, such as when the task needs to be retried, the timeout should not be too large). However, if the Scheduler is eventually unable to enter the SUPPRESSED state, and if there is a new task to be issued after the rejection, then for a period of time, if you do not receive enough resource Offers, you should consider using REVIVE for recovery.
Don't call REVIVE frequently: calling REVIVE clears all filters, and if you call REVIVE frequently, it's equivalent to using a short timeout to reject offer.
Set FrameworkInfo.offer_filters: set this parameter in the configuration of Scheduler to specify the global filters. Currently, the supported parameter is OfferFilters.min_allocatable_resources, which is also configured at the cluster level (specified using-- min_allocatable_resources). The former can configure each role to override the configuration of the latter. Setting the FrameworkInfo.offer_filters with the size of the smallest Offer you want to receive ensures that the Scheduler can better receive enough Offer of the right size.
Operationally, when different Scheduler coexist, you can do the following to ensure that Scheduler can get the resources they need:
Do not share the same Role between Schedulers
Use quota to assign resources to roles
Set the minimum amount of resources allocated
Consider enabling random sorting
Scheduler development example
I put two sample programs on github, using each of the two methods mentioned above.
By implementing the SchedulerDriver interface
Github address: mesos-framework-demo
Language: Java
Because the C++ native library is used, when running the jar package, put the mesoslib.so file in / usr/local/lib, or you can change this path by setting an environment variable:
MESOS_NATIVE_JAVA_LIBRARY=/usr/local/lib/mesoslib.so
Take a look at the code under clone. The work completed is as follows:
1. Set FrameworkInfo, which mainly includes:
User specifies the running user of executor or task
Name specifies the name of Framework
Id specifies the unique identity of the Framework
FailoverTimeout specifies the time to wait for troubleshooting, after which the framework and the tasks running under it will be removed without re-registration.
Role role name
two。 The methods to implement the org.apache.mesos.Scheduler interface mainly include:
Callback when registered () registers successfully
Callback when the resourceOffers () resource Offers arrives
Callback when the status of statusUpdate () task is updated
Callback when reregistered () re-registers
3. Configure the Zk address for discovering Mesos Master
Complete the above configuration and implementation, you can achieve a simple Framework Scheduler, when the registration is successful, in the Mesos / frameworks page, you can see the Framework you launched.
In the example project, mesos.proto is the structural definition of data, in which there are various types and structural relationships of data.
Through HTTP API
Github address: mesos-framework-go-example
Language: golang
For convenience, a ready-made third-party tool mesos-go is used.
Compared to the first method, the third step is no longer to configure the Zk address, but to configure the scheduler interface address of the Mesos:
Url: "http://localhost:5050/api/v1/scheduler", development recommendations
Select the appropriate data storage middleware, such as Zookeeper, Etcd, Mysql
Use multiple instances to ensure high availability
If there are Http requests or data access in the resourceOffers () callback method, it is recommended to increase the caching mechanism while using Filters.refuse_seconds to control the frequency of resourceOffers () callbacks.
After reading the above, do you have any further understanding of what Mesos Framework development is? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.