How to start multiple faust app in the same time?

347 views Asked by At

I'm new user of Faust and don't know how to fix the problem when I ran 3 faust apps in the same time. Specifically:

I have 3 python file, In each, I run 1 service for listening from kafka server. Each file contains code as below, the different in each file is just the TOPIC_INPUT name.

app = faust.App(
    'UserInfoReceive',
    broker= 'kafka://' + SERVER_INPUT + f':{DVWAP_KAFKA_PORT}',
    value_serializer='raw',
)

kafka_topic = app.topic(TOPIC_INPUT)

@app.agent(kafka_topic)
async def userSettingInput(streamInput):
    async for msg in streamInput:
        userResgister(msg)

Expected behavior

Expect 3 python files can run normally and listen to the comming kafka event

Actual behavior

it generates OSError as this img

Hi all,

I'm new user of Faust and don't know how to fix the problem when I ran 3 faust apps in the same time. Specifically:

I have 3 python file, In each, I run 1 service for listening from kafka server. Each file contains code as below, the only difference in each file is the TOPIC_INPUT name. app = faust.App( 'UserInfoReceive', broker= 'kafka://' + SERVER_INPUT + f':{DVWAP_KAFKA_PORT}', value_serializer='raw', )

kafka_topic = app.topic(TOPIC_INPUT)

@app.agent(kafka_topic) async def userSettingInput(streamInput): async for msg in streamInput: userResgister(msg) Expected behavior Expect 3 python files can run normally and listen to the comming kafka event

Actual behavior it generates OSError as this img

image

Versions

Python version: 3.9 Faust version 1.10.4 Operating system WSL Linux Subsystem on Windows Kafka version kafka-python==1.4.7

1

There are 1 answers

0
noertker On

This is happening because each faust worker by default uses the same web_port (6066). You can change this configuration for each additional app instance when you configure it.

app = faust.App(
    'UserInfoReceive',
    broker= 'kafka://' + SERVER_INPUT + f':{DVWAP_KAFKA_PORT}',
    value_serializer='raw',
    web_port=7001 #<- ADD DIFFERENT WEB PORT HERE
)