avatarJames Williams

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

5243

Abstract

name">C</span>:\Users\feng\Kafka\kraft>ls docker-compose.yml <span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>docker-compose up -d [+] Running <span class="hljs-number">2</span>/<span class="hljs-number">2</span>

  • Network kraft_default Created <span class="hljs-number">0.0</span>s
  • Container kraft-kafka<span class="hljs-number">-1</span> Started

<span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES <span class="hljs-number">54342e49</span>a1f2 bitnami/<span class="hljs-name">kafka</span>:latest <span class="hljs-string">"/opt/bitnami/script…"</span> <span class="hljs-number">18</span> seconds ago Up <span class="hljs-number">17</span> seconds <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>:<span class="hljs-number">9092</span>-><span class="hljs-number">9092</span>/tcp kraft-kafka<span class="hljs-number">-1</span> <span class="hljs-number">0.5</span>s</pre></div><h2 id="095a">1.5 Create Kafka topic</h2><p id="0672">We’ll login to the instance and create a test topic in Kafka</p><div id="aaf2"><pre><span class="hljs-comment">## Login to Kafka docker instance</span> C:\Users\feng\Kafka\kraft>docker exec -it kraft-kafka-1 <span class="hljs-string">/bin/bash</span> <span class="hljs-keyword">cd</span> <span class="hljs-string">/opt/bitnami/kafka</span> <span class="hljs-string">/opt/bitnami/kafka</span> <span class="hljs-string">./bin/kafka-topics.sh</span> <span class="hljs-params">--version</span> 3.4.0 <span class="hljs-params">(Commit:2e1947d240607d53)</span>

<span class="hljs-comment">## Create topic named "test_topic"</span> <span class="hljs-string">/opt/bitnami/kafka</span>$ <span class="hljs-string">./bin/kafka-topics.sh</span> <span class="hljs-params">--bootstrap-server</span> localhost<span class="hljs-function">:9092</span> <span class="hljs-params">--create</span> <span class="hljs-params">--replication-factor</span> 1 <span class="hljs-params">--partitions</span> 2 <span class="hljs-params">--topic</span> test_topic WARNING: Due to limitations in metric names, topics with a period <span class="hljs-params">('.')</span> or underscore <span class="hljs-params">('_')</span> could collide. To avoid issues it is best to use either, but not both. Created topic test_topic.

<span class="hljs-comment">## List current topics</span> <span class="hljs-string">/opt/bitnami/kafka</span>$ <span class="hljs-string">./bin/kafka-topics.sh</span> <span class="hljs-params">--bootstrap-server</span> localhost<span class="hljs-function">:9092</span> <span class="hljs-params">--list</span> test_topic</pre></div><p id="8304">So by now we have a Kafka docker instance running successfully.</p><h1 id="80ee">2 Run sanity checks using simple producer/consumer app codes</h1><h2 id="b504">2.1 Setup producer/consumer Dev ENV</h2><div id="8e5b"><pre>## Create conda env <span class="hljs-keyword">for</span> Kafka producer <span class="hljs-keyword">and</span> cosumer <span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>conda create -n kafka_env python=<span class="hljs-number">3.10</span> ... <span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>conda activate kafka_env

Install kafka-python <span class="hljs-built_in">package</span>

(kafka_env) <span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>pip install kafka-python ... (kafka_env) <span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>pip list | grep kafka kafka-python <span class="hljs-number">2.0</span><span class="hljs-number">.2</span>

Install Faker <span class="hljs-built_in">package</span> to generate dummy messages

(kafka_env) <span class="hljs-name">C</span>:\Users\feng\Kafka\kraft>pip install Faker ... (kafka_env) <span class="hljs-name">C</span>:\Users<span class="hljs-number">6119811</span>\Kafka\kraft>pip list | grep Faker Faker <span class="hljs-number">17.3</span><span class="hljs-number">.0</span></pre></div><h2 id="6701">2.2 Code examples</h2><p id="c7dc">Now we can use VSCode to create producer/consumer files.</p><p id="fc6a">Producer generate fake user info as JSON load sending to Kafka topic “test_topic”. producer.py is like following.</p><div id="8801"><pre><span class="hljs-keyword">import</span> time <span class="hljs-keyword">import</span> json <span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> datetime <span class="hljs-keyword">from</span> kafka <span class="hljs-keyword">import</span> KafkaProducer <span class="hljs-keyword">from</span> faker <span class="hljs-keyword">import</span> Faker

<span class="hljs-comment"># JSON messages needs to be serialized</span> <span class="hljs-comment"># when sending to Kafka topic </span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">json_serializer</span>(<span class="hljs-params">message</span>): <span class="hljs-keyword">return</span> json.dumps(message

Options

).encode(<span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Kafka Producer</span> producer = KafkaProducer( bootstrap_servers=[<span class="hljs-string">'localhost:9092'</span>], value_serializer=json_serializer ) <span class="hljs-keyword">if</span> name == <span class="hljs-string">'main'</span>: fake = Faker() <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>): <span class="hljs-comment"># Generate a fake JSON message</span> name = fake.name() email = fake.email() city = fake.city() fake_message = { <span class="hljs-string">"name"</span>: name, <span class="hljs-string">"email"</span>: email, <span class="hljs-string">"city"</span>: city }

    <span class="hljs-comment"># Send fake JSON message to Kafka topic</span>
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f'<span class="hljs-subst">{datetime.now()}</span>: Message = <span class="hljs-subst">{<span class="hljs-built_in">str</span>(fake_message)}</span>'</span>)
    producer.send(<span class="hljs-string">'test_topic'</span>, fake_message)
                                                          
    time.sleep(<span class="hljs-number">1</span>)</pre></div><p id="6594">And here is our consumer.py</p><div id="a19b"><pre><span class="hljs-keyword">import</span> json 

<span class="hljs-keyword">from</span> kafka <span class="hljs-keyword">import</span> KafkaConsumer

<span class="hljs-keyword">if</span> name == <span class="hljs-string">'main'</span>: <span class="hljs-comment"># Kafka Consumer</span> consumer = KafkaConsumer( <span class="hljs-string">'test_topic'</span>, bootstrap_servers=<span class="hljs-string">'localhost:9092'</span>, auto_offset_reset=<span class="hljs-string">'earliest'</span> ) <span class="hljs-keyword">for</span> message <span class="hljs-keyword">in</span> consumer: <span class="hljs-built_in">print</span>(json.loads(message.value))</pre></div><p id="8d09">OK, now let’s start consumer and run producer to send some fake message for a sanity check.</p><div id="572f"><pre><span class="hljs-comment"># Run producer</span> (kafka_env) C:\Users\feng\Kafka\kraft>python producer.py 2023-02-25 18:48:41.143953: Message = {<span class="hljs-string">'name'</span>: <span class="hljs-string">'Susan Best'</span>, <span class="hljs-string">'email'</span>: <span class="hljs-string">'[email protected]'</span>, <span class="hljs-string">'city'</span>: <span class="hljs-string">'Kellytown'</span>} 2023-02-25 18:48:42.160545: Message = {<span class="hljs-string">'name'</span>: <span class="hljs-string">'James Wilson'</span>, <span class="hljs-string">'email'</span>: <span class="hljs-string">'[email protected]'</span>, <span class="hljs-string">'city'</span>: <span class="hljs-string">'Lake Bryanfort'</span>} 2023-02-25 18:48:43.177933: Message = {<span class="hljs-string">'name'</span>: <span class="hljs-string">'Haley Brooks'</span>, <span class="hljs-string">'email'</span>: <span class="hljs-string">'[email protected]'</span>, <span class="hljs-string">'city'</span>: <span class="hljs-string">'East Janetburgh'</span>}

<span class="hljs-comment"># Monitor consumer</span> (kafka_env) C:\Users\feng\Kafka\kraft>python consumer.py {<span class="hljs-string">'name'</span>: <span class="hljs-string">'Susan Best'</span>, <span class="hljs-string">'email'</span>: <span class="hljs-string">'[email protected]'</span>, <span class="hljs-string">'city'</span>: <span class="hljs-string">'Kellytown'</span>} {<span class="hljs-string">'name'</span>: <span class="hljs-string">'James Wilson'</span>, <span class="hljs-string">'email'</span>: <span class="hljs-string">'[email protected]'</span>, <span class="hljs-string">'city'</span>: <span class="hljs-string">'Lake Bryanfort'</span>} {<span class="hljs-string">'name'</span>: <span class="hljs-string">'Haley Brooks'</span>, <span class="hljs-string">'email'</span>: <span class="hljs-string">'[email protected]'</span>, <span class="hljs-string">'city'</span>: <span class="hljs-string">'East Janetburgh'</span>}</pre></div><p id="3143">Great, our Kafka Docker instance and simple applications are working as expected!</p><p id="79d6">Happy Reading!</p><div id="2213" class="link-block"> <a href="https://medium.com/@fengliplatform/membership"> <div> <div> <h2>Join Medium with my referral link - Feng Li</h2> <div><h3>Writing helps ourselves, sharing helps many. It started from study notes for myself with no pressure of perfection…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*K9psL5RefQfuKkzr)"></div> </div> </div> </a> </div></article></body>

The Book That Made Me Change My Business Model

How to go from hard-to-manage hourly rates to profitable fees.

Photo by Suliman Sallehi from Pexels

As a business owner, I’ve read hoards of business books. Page after page, I searched for a silver bullet. Was it a perfect business plan I needed? Or did I need to be like Peter Thiel? What about Bill Gates and Steve Job’s many successes? Here’s one thing each of them had in common: They had to sell something.

Years of trying and failing at running companies taught me something — sales is a business's fuel. Sure business owners should write business plans. They should think about culture. Good leaders should inspire, nurture and advance the people who work for them. But how will any of this work if you can’t make payroll? For me, sales books reign supreme.

I have no issues with business books, but I think we overestimate their impact while we demonize sales. We envision a dude selling us a car knowing there’s no engine. But after years of struggling with my business, I studied sales. It’s my least favorite part about running a business, but at the end of the day, I gotta make it rain so that my ideas have a life.

Value-Based Fees Changed My Business Model

Alan Weiss is a genius. When I learn that entrepreneurs haven’t heard of him, I go to my Amazon account and buy “Valued-Based Fees.” I send them what I believe to be a manifesto for running a profitable and rewarding business. This work of art is too beautiful not to share. Once I send them the book, I check twice a week to see if they’ve read it. I know this book will change their lives; it will amplify their business 10-fold.

Like many software engineers, I’ve worked for tons of people. I’ve helped create tons of value. From the early days of the internet to now, I’ve stayed passionate and vigilant. Always learning. But the hours I spent simply don’t add up. The 80+ hour weeks seemed worth it. I had a dream of making a mark on technology. I thought success would come from sleeping under my desk. I missed countless dinners. I lived with bags under my eyes. Effort through hours was the only thing I knew.

I broke away from the shackles of corporate America. I escaped from the software industry’s sprints. I took a leap and started my own business. It comes as no surprise that I did everything wrong until I read Alan Weiss.

My personal struggle with business growth went on for years until I saw a YouTube video with Alan Weiss. His matter-of-fact tone, resonated with me. His refusal to lower himself to customers' demands made me cheer. One video at a time, and after reading his book, I learned how to better value myself, my team, and my company.

Why Engineers Should Read This Book

Software engineers deliver tons of value, but they don’t get paid for it. Sure, they get nice salaries compared to the average profession. But the vast majority of software engineers do not reap the reward for their ingenuity, talent, and hard work.

As a freelancers or services business, you deserve to get what you’re worth. To do so you have to ask for it. But, how? First, you must understand what the customer wants. Once you know how valuable a project is to them, you can work out what your fee should be.

Establishing value is key. On page seven in Alan Weiss’ book, he presents a list of questions to help you understand business value. Even if you’re at a product company, understanding how to ask questions is essential. Proper questions ensure that you save your and the company’s time. If you’re tired of working on feature after feature only to learn the number one priority was something else, learn to ask questions. Start on page seven in the book.

To get a respected seat at the decision table, you must learn the vocabulary of value. You should understand that building APIs increases evaluations. Creating data warehouses allow businesses to understand sales and their customers. Building integration to third-party technology stacks extends a businesses’ reach, enabling better functionality and happier customers.

If you make a business multiple millions, why would you accept low thousands? Why would you reduce yourself to a higher hourly rate, when you provide more value? Why are you accepting a nice computer and a few monitors as fair compensation for the value you deliver?

Hourly Billing is Insane

Alan Weiss points out that charging by the hour is lunacy. I couldn’t agree more. Customers haggle over hourly rates without considering the business objective. It’s a game to get you to reduce your prices. It’s a badge of honor to beat a vendor over the head, in order to impress their bosses — who’re also not focused on business value.

Business leaders complain when their business goals aren’t met, but they insist on focusing on hourly rates. Vice Presidents and directors of engineering, look to add engineers to their sprints at the lowest rate but expect the highest value.

WTF?

Your team is managed by them, but you take the heat when projects go belly-up. When aesthetically pleasing sprints fail, their index fingers come out — pointed at you, the vendor. They focus more on spreadsheets and hours worked than positive outcomes for their customers.

Alan Weiss rips this nonsense and insanity to shreds.

Don’t Create Statement of Works, Make Simple Proposals

Statement of works (SOWs) represents another way to say: Show me how many hours you’re going to work and how each hour costs? Some bean counter somewhere will line-item each bullet in the SOW — hoping simple division will give them a sense of value.

In Value-based Fees, the title of one chapter is “The Lunacy of Time-and-Material Models.” One of the mind-blowing concepts is to work the minimum amount of hours for the maximum value. How the hell can you do that if you’re charging for each hour?

The chapter goes on to say that you must educate the buyer correctly. You must break the false shackles that make you a servant. This ancient thinking doesn’t serve you nor the customer. Thinking of yourself as a peer is the first step to freedom. Your expertise is helping them amass value. If you do it the right way, you’ll be seen as a partner — not as a subordinate.

When you realize it’s a partnership and not a work-for relationship, you’ll create proposals with qualitative deliverables. As Alan points out, your job is to “improve the condition of your customer.” Make them better. Improve their business. Provide advice and guidance that takes them to the next level.

The Impact Valued-Based Fees Had On My Business

Quadruple growth.

By ditching staff augmentation and focusing on value, my business changed. I eliminated selling JavaScript guys and allowing them to be managed by someone else. I did the hard work of figuring out what we do best. I studied different sales models and learned how to package up services.

“How to Charge — and Get — What You’re Worth” is the subtitle. To get what you’re worth, you have to know your industry hands down. You have to become a student of customers, learn their language, and create value. Ask yourself what’s more valuable: Following what a customer thinks they want, or providing your expertise and delivering value?

Valued-Based Fees will allow you to spend less time for more revenue. It will give you the tools to succeed. There’s even a section describing how to create a proposal. If you’re like me, you’ll be surprised. He dispels the myth of whizbang proposals which take hours to develop. Instead, he packs his proposals with tons of value, clear objectives, and simple ways to measure success.

I should point out that I don’t know Alan Weiss. I never met him. No one told me to write this nor do I get paid for this book recommendation. I should mention, I read this book countless times. It took a minute to work out how the wisdom applied to my business. With my team, I used Alan’s framework to tweak my sales approach. I figured who my customers are. I learned what to say. I locked myself in my office until I figured out how I offered value, and how to tell people about it.

Wherever you are, and whatever you’re doing, thank you, Alan Weiss.

Get the book here.

Innovation
Technology
Entrepreneurship
Leadership
Business
Recommended from ReadMedium